<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="時光的个人博客" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
	  <meta name="referrer" content="no-referrer" />

      <title> 時光</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="時光" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
      
      <a class="forkMe" href="https://github.com/Shen-Yu/hexo-theme-ayer"
        target="_blank"><img width="149" height="149" src="/images/forkme.png"
          class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover1.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">時光</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.staticfile.org/typed.js/2.0.12/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-Git 常用命令速查"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/Git%20%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E9%80%9F%E6%9F%A5/"
    >Git常用命令速查</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Git%20%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E9%80%9F%E6%9F%A5/" class="article-date">
  <time datetime="2022-01-22T15:09:16.390Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%A5%BD%E8%AE%B0%E6%80%A7%E4%B8%8D%E5%A6%82%E7%83%82%E7%AC%94%E5%A4%B4/">好记性不如烂笔头</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="一、-Git常用命令速查"><a href="#一、-Git常用命令速查" class="headerlink" title="一、 Git常用命令速查"></a>一、 Git常用命令速查</h2><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">git branch <span class="comment"># 查看本地所有分支</span></span><br><span class="line">git status <span class="comment"># 查看当前状态 </span></span><br><span class="line">git commit <span class="comment"># 提交 </span></span><br><span class="line">git branch -a <span class="comment"># 查看所有的分支</span></span><br><span class="line">git branch -r <span class="comment"># 查看远程所有分支</span></span><br><span class="line">git commit -am <span class="string">&quot;init&quot;</span> <span class="comment"># 提交并且加注释 </span></span><br><span class="line">git remote add origin git@192.168.1.119:ndshow</span><br><span class="line">git push origin master <span class="comment"># 将文件给推到服务器上 </span></span><br><span class="line">git remote show origin <span class="comment"># 显示远程库origin里的资源 </span></span><br><span class="line">git push origin master:develop</span><br><span class="line">git push origin master:hb-dev <span class="comment"># 将本地库与服务器上的库进行关联 </span></span><br><span class="line">git checkout --track origin/dev <span class="comment"># 切换到远程dev分支</span></span><br><span class="line">git branch -D master develop <span class="comment"># 删除本地库develop</span></span><br><span class="line">git checkout -b dev <span class="comment"># 建立一个新的本地分支dev</span></span><br><span class="line">git merge origin/dev <span class="comment"># 将分支dev与当前分支进行合并</span></span><br><span class="line">git checkout dev <span class="comment"># 切换到本地dev分支</span></span><br><span class="line">git remote show <span class="comment"># 查看远程库</span></span><br><span class="line">git add .</span><br><span class="line">git <span class="built_in">rm</span> 文件名(包括路径) <span class="comment"># 从git中删除指定文件</span></span><br><span class="line">git <span class="built_in">clone</span> git://github.com/schacon/grit.git <span class="comment"># 从服务器上将代码给拉下来</span></span><br><span class="line">git config --list <span class="comment"># 看所有用户</span></span><br><span class="line">git ls-files <span class="comment"># 看已经被提交的</span></span><br><span class="line">git <span class="built_in">rm</span> [file name] <span class="comment"># 删除一个文件</span></span><br><span class="line">git commit -a <span class="comment"># 提交当前repos的所有的改变</span></span><br><span class="line">git add [file name] <span class="comment"># 添加一个文件到git index</span></span><br><span class="line">git commit -v <span class="comment"># 当你用－v参数的时候可以看commit的差异</span></span><br><span class="line">git commit -m <span class="string">&quot;This is the message describing the commit&quot;</span> <span class="comment"># 添加commit信息</span></span><br><span class="line">git commit -a <span class="comment"># -a是代表add，把所有的change加到git index里然后再commit</span></span><br><span class="line">git commit -a -v <span class="comment"># 一般提交命令</span></span><br><span class="line">git <span class="built_in">log</span> <span class="comment"># 看你commit的日志</span></span><br><span class="line">git diff <span class="comment"># 查看尚未暂存的更新</span></span><br><span class="line">git <span class="built_in">rm</span> a.a <span class="comment"># 移除文件(从暂存区和工作区中删除)</span></span><br><span class="line">git <span class="built_in">rm</span> --cached a.a <span class="comment"># 移除文件(只从暂存区中删除)</span></span><br><span class="line">git commit -m <span class="string">&quot;remove&quot;</span> <span class="comment"># 移除文件(从Git中删除)</span></span><br><span class="line">git <span class="built_in">rm</span> -f a.a <span class="comment"># 强行移除修改后文件(从暂存区和工作区中删除)</span></span><br><span class="line">git diff --cached 或 $ git diff --staged <span class="comment"># 查看尚未提交的更新</span></span><br><span class="line">git stash push <span class="comment"># 将文件给push到一个临时空间中</span></span><br><span class="line">git stash pop <span class="comment"># 将文件从临时空间pop下来</span></span><br><span class="line">\---------------------------------------------------------</span><br><span class="line">git remote add origin git@github.com:username/Hello-World.git</span><br><span class="line">git push origin master <span class="comment"># 将本地项目给提交到服务器中</span></span><br><span class="line">\-----------------------------------------------------------</span><br><span class="line">git pull <span class="comment"># 本地与服务器端同步</span></span><br><span class="line">\-----------------------------------------------------------------</span><br><span class="line">git push (远程仓库名) (分支名) <span class="comment"># 将本地分支推送到服务器上去。</span></span><br><span class="line">git push origin serverfix:awesomebranch</span><br><span class="line">\------------------------------------------------------------------</span><br><span class="line">git fetch <span class="comment"># 相当于是从远程获取最新版本到本地，不会自动merge</span></span><br><span class="line">git commit -a -m <span class="string">&quot;log_message&quot;</span> <span class="comment"># (-a是提交所有改动，-m是加入log信息) 本地修改同步至服务器端 ：</span></span><br><span class="line">git branch branch_0.1 master <span class="comment"># 从主分支master创建branch_0.1分支</span></span><br><span class="line">git branch -m branch_0.1 branch_1.0 <span class="comment"># 将branch_0.1重命名为branch_1.0</span></span><br><span class="line">git checkout branch_1.0/master <span class="comment"># 切换到branch_1.0/master分支</span></span><br><span class="line"><span class="built_in">du</span> -hs</span><br><span class="line"></span><br><span class="line">git branch <span class="comment"># 删除远程branch</span></span><br><span class="line">git push origin :branch_remote_name</span><br><span class="line">git branch -r -d branch_remote_name</span><br></pre></td></tr></table></figure>

<p>初始化版本库，并提交到远程服务器端</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> WebApp</span><br><span class="line"><span class="built_in">cd</span> WebApp</span><br><span class="line">git init <span class="comment"># 本地初始化</span></span><br><span class="line"><span class="built_in">touch</span> README</span><br><span class="line">git add README <span class="comment"># 添加文件</span></span><br><span class="line">git commit -m <span class="string">&#x27;first commit&#x27;</span></span><br><span class="line">git remote add origin git@github.com:daixu/WebApp.git</span><br></pre></td></tr></table></figure>

<p>增加一个远程服务器端</p>
<p>上面的命令会增加URL地址为‘<a href="mailto:&#103;&#105;&#x74;&#64;&#103;&#105;&#x74;&#104;&#117;&#98;&#x2e;&#x63;&#x6f;&#109;">&#103;&#105;&#x74;&#64;&#103;&#105;&#x74;&#104;&#117;&#98;&#x2e;&#x63;&#x6f;&#109;</a>:daixu&#x2F;WebApp.git’，名称为origin的远程服务器库，以后提交代码的时候只需要使用 origin别名即可</p>
<h2 id="二、-Git-命令速查表"><a href="#二、-Git-命令速查表" class="headerlink" title="二、 Git 命令速查表"></a>二、 Git 命令速查表</h2><h3 id="1、常用的Git命令"><a href="#1、常用的Git命令" class="headerlink" title="1、常用的Git命令"></a>1、常用的Git命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git add</td>
<td>添加至暂存区</td>
</tr>
<tr>
<td>git add–interactive</td>
<td>交互式添加</td>
</tr>
<tr>
<td>git apply</td>
<td>应用补丁</td>
</tr>
<tr>
<td>git am</td>
<td>应用邮件格式补丁</td>
</tr>
<tr>
<td>git annotate</td>
<td>同义词，等同于 git blame</td>
</tr>
<tr>
<td>git archive</td>
<td>文件归档打包</td>
</tr>
<tr>
<td>git bisect</td>
<td>二分查找</td>
</tr>
<tr>
<td>git blame</td>
<td>文件逐行追溯</td>
</tr>
<tr>
<td>git branch</td>
<td>分支管理</td>
</tr>
<tr>
<td>git cat-file</td>
<td>版本库对象研究工具</td>
</tr>
<tr>
<td>git checkout</td>
<td>检出到工作区、切换或创建分支</td>
</tr>
<tr>
<td>git cherry-pick</td>
<td>提交拣选</td>
</tr>
<tr>
<td>git citool</td>
<td>图形化提交，相当于 git gui 命令</td>
</tr>
<tr>
<td>git clean</td>
<td>清除工作区未跟踪文件</td>
</tr>
<tr>
<td>git clone</td>
<td>克隆版本库</td>
</tr>
<tr>
<td>git commit</td>
<td>提交</td>
</tr>
<tr>
<td>git config</td>
<td>查询和修改配置</td>
</tr>
<tr>
<td>git describe</td>
<td>通过里程碑直观地显示提交ID</td>
</tr>
<tr>
<td>git diff</td>
<td>差异比较</td>
</tr>
<tr>
<td>git difftool</td>
<td>调用图形化差异比较工具</td>
</tr>
<tr>
<td>git fetch</td>
<td>获取远程版本库的提交</td>
</tr>
<tr>
<td>git format-patch</td>
<td>创建邮件格式的补丁文件。参见 git am 命令</td>
</tr>
<tr>
<td>git grep</td>
<td>文件内容搜索定位工具</td>
</tr>
<tr>
<td>git gui</td>
<td>基于Tcl&#x2F;Tk的图形化工具，侧重提交等操作</td>
</tr>
<tr>
<td>git help</td>
<td>帮助</td>
</tr>
<tr>
<td>git init</td>
<td>版本库初始化</td>
</tr>
<tr>
<td>git init-db*</td>
<td>同义词，等同于 git init</td>
</tr>
<tr>
<td>git log</td>
<td>显示提交日志</td>
</tr>
<tr>
<td>git merge</td>
<td>分支合并</td>
</tr>
<tr>
<td>git mergetool</td>
<td>图形化冲突解决</td>
</tr>
<tr>
<td>git mv</td>
<td>重命名</td>
</tr>
<tr>
<td>git pull</td>
<td>拉回远程版本库的提交</td>
</tr>
<tr>
<td>git push</td>
<td>推送至远程版本库</td>
</tr>
<tr>
<td>git rebase</td>
<td>分支变基</td>
</tr>
<tr>
<td>git rebase–interactive</td>
<td>交互式分支变基</td>
</tr>
<tr>
<td>git reflog</td>
<td>分支等引用变更记录管理</td>
</tr>
<tr>
<td>git remote</td>
<td>远程版本库管理</td>
</tr>
<tr>
<td>git repo-config*</td>
<td>同义词，等同于 git config</td>
</tr>
<tr>
<td>git reset</td>
<td>重置改变分支“游标”指向</td>
</tr>
<tr>
<td>git rev-parse</td>
<td>将各种引用表示法转换为哈希值等</td>
</tr>
<tr>
<td>git revert</td>
<td>反转提交</td>
</tr>
<tr>
<td>git rm</td>
<td>删除文件</td>
</tr>
<tr>
<td>git show</td>
<td>显示各种类型的对象</td>
</tr>
<tr>
<td>git stage*</td>
<td>同义词，等同于 git add</td>
</tr>
<tr>
<td>git stash</td>
<td>保存和恢复进度</td>
</tr>
<tr>
<td>git status</td>
<td>显示工作区文件状态</td>
</tr>
<tr>
<td>git tag</td>
<td>里程碑管理</td>
</tr>
</tbody></table>
<h3 id="2、对象库操作相关命令"><a href="#2、对象库操作相关命令" class="headerlink" title="2、对象库操作相关命令"></a>2、对象库操作相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git commit-tree</td>
<td>从树对象创建提交</td>
</tr>
<tr>
<td>git hash-object</td>
<td>从标准输入或文件计算哈希值或创建对象</td>
</tr>
<tr>
<td>git ls-files</td>
<td>显示工作区和暂存区文件</td>
</tr>
<tr>
<td>git ls-tree</td>
<td>显示树对象包含的文件</td>
</tr>
<tr>
<td>git mktag</td>
<td>读取标准输入创建一个里程碑对象</td>
</tr>
<tr>
<td>git mktree</td>
<td>读取标准输入创建一个树对象</td>
</tr>
<tr>
<td>git read-tree</td>
<td>读取树对象到暂存区</td>
</tr>
<tr>
<td>git update-index</td>
<td>工作区内容注册到暂存区及暂存区管理</td>
</tr>
<tr>
<td>git unpack-file</td>
<td>创建临时文件包含指定 blob 的内容</td>
</tr>
<tr>
<td>git write-tree</td>
<td>从暂存区创建一个树对象</td>
</tr>
</tbody></table>
<h3 id="3、引用操作相关命令"><a href="#3、引用操作相关命令" class="headerlink" title="3、引用操作相关命令"></a>3、引用操作相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git check-ref-format</td>
<td>检查引用名称是否符合规范</td>
</tr>
<tr>
<td>git for-each-ref</td>
<td>引用迭代器，用于shell编程</td>
</tr>
<tr>
<td>git ls-remote</td>
<td>显示远程版本库的引用</td>
</tr>
<tr>
<td>git name-rev</td>
<td>将提交ID显示为友好名称</td>
</tr>
<tr>
<td>git peek-remote*</td>
<td>过时命令，请使用 git ls-remote</td>
</tr>
<tr>
<td>git rev-list</td>
<td>显示版本范围</td>
</tr>
<tr>
<td>git show-branch</td>
<td>显示分支列表及拓扑关系</td>
</tr>
<tr>
<td>git show-ref</td>
<td>显示本地引用</td>
</tr>
<tr>
<td>git symbolic-ref</td>
<td>显示或者设置符号引用</td>
</tr>
<tr>
<td>git update-ref</td>
<td>更新引用的指向</td>
</tr>
<tr>
<td>git verify-tag</td>
<td>校验 GPG 签名的Tag</td>
</tr>
</tbody></table>
<h3 id="4、版本库管理相关命令"><a href="#4、版本库管理相关命令" class="headerlink" title="4、版本库管理相关命令"></a>4、版本库管理相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git count-objects</td>
<td>显示松散对象的数量和磁盘占用</td>
</tr>
<tr>
<td>git filter-branch</td>
<td>版本库重构</td>
</tr>
<tr>
<td>git fsck</td>
<td>对象库完整性检查</td>
</tr>
<tr>
<td>git fsck-objects*</td>
<td>同义词，等同于 git fsck</td>
</tr>
<tr>
<td>git gc</td>
<td>版本库存储优化</td>
</tr>
<tr>
<td>git index-pack</td>
<td>从打包文件创建对应的索引文件</td>
</tr>
<tr>
<td>git lost-found*</td>
<td>过时，请使用 git fsck –lost-found 命令</td>
</tr>
<tr>
<td>git pack-objects</td>
<td>从标准输入读入对象ID，打包到文件</td>
</tr>
<tr>
<td>git pack-redundant</td>
<td>查找多余的 pack 文件</td>
</tr>
<tr>
<td>git pack-refs</td>
<td>将引用打包到 .git&#x2F;packed-refs 文件中</td>
</tr>
<tr>
<td>git prune</td>
<td>从对象库删除过期对象</td>
</tr>
<tr>
<td>git prune-packed</td>
<td>将已经打包的松散对象删除</td>
</tr>
<tr>
<td>git relink</td>
<td>为本地版本库中相同的对象建立硬连接</td>
</tr>
<tr>
<td>git repack</td>
<td>将版本库未打包的松散对象打包</td>
</tr>
<tr>
<td>git show-index</td>
<td>读取包的索引文件，显示打包文件中的内容</td>
</tr>
<tr>
<td>git unpack-objects</td>
<td>从打包文件释放文件</td>
</tr>
<tr>
<td>git verify-pack</td>
<td>校验对象库打包文件</td>
</tr>
</tbody></table>
<h3 id="5、数据传输相关命令"><a href="#5、数据传输相关命令" class="headerlink" title="5、数据传输相关命令"></a>5、数据传输相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git fetch-pack</td>
<td>执行 git fetch 或 git pull 命令时在本地执行此命令，用于从其他版本库获取缺失的对象</td>
</tr>
<tr>
<td>git receive-pack</td>
<td>执行 git push 命令时在远程执行的命令，用于接受推送的数据</td>
</tr>
<tr>
<td>git send-pack</td>
<td>执行 git push 命令时在本地执行的命令，用于向其他版本库推送数据</td>
</tr>
<tr>
<td>git upload-archive</td>
<td>执行 git archive –remote 命令基于远程版本库创建归档时，远程版本库执行此命令传送归档</td>
</tr>
<tr>
<td>git upload-pack</td>
<td>执行 git fetch 或 git pull 命令时在远程执行此命令，将对象打包、上传</td>
</tr>
</tbody></table>
<h3 id="6、邮件相关命令"><a href="#6、邮件相关命令" class="headerlink" title="6、邮件相关命令"></a>6、邮件相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git imap-send</td>
<td>将补丁通过 IMAP 发送</td>
</tr>
<tr>
<td>git mailinfo</td>
<td>从邮件导出提交说明和补丁</td>
</tr>
<tr>
<td>git mailsplit</td>
<td>将 mbox 或 Maildir 格式邮箱中邮件逐一提取为文件</td>
</tr>
<tr>
<td>git request-pull</td>
<td>创建包含提交间差异和执行PULL操作地址的信息</td>
</tr>
<tr>
<td>git send-email</td>
<td>发送邮件</td>
</tr>
</tbody></table>
<h3 id="7、协议相关命令"><a href="#7、协议相关命令" class="headerlink" title="7、协议相关命令"></a>7、协议相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git daemon</td>
<td>实现Git协议</td>
</tr>
<tr>
<td>git http-backend</td>
<td>实现HTTP协议的CGI程序，支持智能HTTP协议</td>
</tr>
<tr>
<td>git instaweb</td>
<td>即时启动浏览器通过 gitweb 浏览当前版本库</td>
</tr>
<tr>
<td>git shell</td>
<td>受限制的shell，提供仅执行Git命令的SSH访问</td>
</tr>
<tr>
<td>git update-server-info</td>
<td>更新哑协议需要的辅助文件</td>
</tr>
<tr>
<td>git http-fetch</td>
<td>通过HTTP协议获取版本库</td>
</tr>
<tr>
<td>git http-push</td>
<td>通过HTTP&#x2F;DAV协议推送</td>
</tr>
<tr>
<td>git remote-ext</td>
<td>由Git命令调用，通过外部命令提供扩展协议支持</td>
</tr>
<tr>
<td>git remote-fd</td>
<td>由Git命令调用，使用文件描述符作为协议接口</td>
</tr>
<tr>
<td>git remote-ftp</td>
<td>由Git命令调用，提供对FTP协议的支持</td>
</tr>
<tr>
<td>git remote-ftps</td>
<td>由Git命令调用，提供对FTPS协议的支持</td>
</tr>
<tr>
<td>git remote-http</td>
<td>由Git命令调用，提供对HTTP协议的支持</td>
</tr>
<tr>
<td>git remote-https</td>
<td>由Git命令调用，提供对HTTPS协议的支持</td>
</tr>
<tr>
<td>git remote-testgit</td>
<td>协议扩展示例脚本</td>
</tr>
</tbody></table>
<h3 id="8、版本库转换和交互相关命令"><a href="#8、版本库转换和交互相关命令" class="headerlink" title="8、版本库转换和交互相关命令"></a>8、版本库转换和交互相关命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git archimport</td>
<td>导入Arch版本库到Git</td>
</tr>
<tr>
<td>git bundle</td>
<td>提交打包和解包，以便在不同版本库间传递</td>
</tr>
<tr>
<td>git cvsexportcommit</td>
<td>将Git的一个提交作为一个CVS检出</td>
</tr>
<tr>
<td>git cvsimport</td>
<td>导入CVS版本库到Git。或者使用 cvs2git</td>
</tr>
<tr>
<td>git cvsserver</td>
<td>Git的CVS协议模拟器，可供CVS命令访问Git版本库</td>
</tr>
<tr>
<td>git fast-export</td>
<td>将提交导出为 git-fast-import 格式</td>
</tr>
<tr>
<td>git fast-import</td>
<td>其他版本库迁移至Git的通用工具</td>
</tr>
<tr>
<td>git svn</td>
<td>Git 作为前端操作 Subversion</td>
</tr>
</tbody></table>
<h3 id="9、合并相关的辅助命令"><a href="#9、合并相关的辅助命令" class="headerlink" title="9、合并相关的辅助命令"></a>9、合并相关的辅助命令</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git merge-base</td>
<td>供其他脚本调用，找到两个或多个提交最近的共同祖先</td>
</tr>
<tr>
<td>git merge-file</td>
<td>针对文件的两个不同版本执行三向文件合并</td>
</tr>
<tr>
<td>git merge-index</td>
<td>对index中的冲突文件调用指定的冲突解决工具</td>
</tr>
<tr>
<td>git merge-octopus</td>
<td>合并两个以上分支。参见 git merge 的octopus合并策略</td>
</tr>
<tr>
<td>git merge-one-file</td>
<td>由 git merge-index 调用的标准辅助程序</td>
</tr>
<tr>
<td>git merge-ours</td>
<td>合并使用本地版本，抛弃他人版本。参见 git merge 的ours合并策略</td>
</tr>
<tr>
<td>git merge-recursive</td>
<td>针对两个分支的三向合并。参见 git merge 的recursive合并策略</td>
</tr>
<tr>
<td>git merge-resolve</td>
<td>针对两个分支的三向合并。参见 git merge 的resolve合并策略</td>
</tr>
<tr>
<td>git merge-subtree</td>
<td>子树合并。参见 git merge 的 subtree 合并策略</td>
</tr>
<tr>
<td>git merge-tree</td>
<td>显式三向合并结果，不改变暂存区</td>
</tr>
<tr>
<td>git fmt-merge-msg</td>
<td>供执行合并操作的脚本调用，用于创建一个合并提交说明</td>
</tr>
<tr>
<td>git rerere</td>
<td>重用所记录的冲突解决方案</td>
</tr>
</tbody></table>
<h3 id="10、-杂项"><a href="#10、-杂项" class="headerlink" title="10、 杂项"></a>10、 杂项</h3><table>
<thead>
<tr>
<th>命令</th>
<th>简要说明</th>
</tr>
</thead>
<tbody><tr>
<td>git bisect–helper</td>
<td>由 git bisect 命令调用，确认二分查找进度</td>
</tr>
<tr>
<td>git check-attr</td>
<td>显示某个文件是否设置了某个属性</td>
</tr>
<tr>
<td>git checkout-index</td>
<td>从暂存区拷贝文件至工作区</td>
</tr>
<tr>
<td>git cherry</td>
<td>查找没有合并到上游的提交</td>
</tr>
<tr>
<td>git diff-files</td>
<td>比较暂存区和工作区，相当于 git diff –raw</td>
</tr>
<tr>
<td>git diff-index</td>
<td>比较暂存区和版本库，相当于 git diff –cached –raw</td>
</tr>
<tr>
<td>git diff-tree</td>
<td>比较两个树对象，相当于 git diff –raw A B</td>
</tr>
<tr>
<td>git difftool–helper</td>
<td>由 git difftool 命令调用，默认要使用的差异比较工具</td>
</tr>
<tr>
<td>git get-tar-commit-id</td>
<td>从 git archive 创建的 tar 包中提取提交ID</td>
</tr>
<tr>
<td>git gui–askpass</td>
<td>命令 git gui 的获取用户口令输入界面</td>
</tr>
<tr>
<td>git notes</td>
<td>提交评论管理</td>
</tr>
<tr>
<td>git patch-id</td>
<td>补丁过滤行号和空白字符后生成补丁唯一ID</td>
</tr>
<tr>
<td>git quiltimport</td>
<td>将Quilt补丁列表应用到当前分支</td>
</tr>
<tr>
<td>git replace</td>
<td>提交替换</td>
</tr>
<tr>
<td>git shortlog</td>
<td>对 git log 的汇总输出，适合于产品发布说明</td>
</tr>
<tr>
<td>git stripspace</td>
<td>删除空行，供其他脚本调用</td>
</tr>
<tr>
<td>git submodule</td>
<td>子模组管理</td>
</tr>
<tr>
<td>git tar-tree</td>
<td>过时命令，请使用 git archive</td>
</tr>
<tr>
<td>git var</td>
<td>显示 Git 环境变量</td>
</tr>
<tr>
<td>git web–browse</td>
<td>启动浏览器以查看目录或文件</td>
</tr>
<tr>
<td>git whatchanged</td>
<td>显示提交历史及每次提交的改动</td>
</tr>
<tr>
<td>git-mergetool–lib</td>
<td>包含于其他脚本中，提供合并&#x2F;差异比较工具的选择和执行</td>
</tr>
<tr>
<td>git-parse-remote</td>
<td>包含于其他脚本中，提供操作远程版本库的函数</td>
</tr>
<tr>
<td>git-sh-setup</td>
<td>包含于其他脚本中，提供 shell 编程的函数库</td>
</tr>
</tbody></table>
<p>Git 常用命令速查表。点击查看大图。</p>
<p><a target="_blank" rel="noopener" href="http://files.jb51.net/file_images/article/201409/git_big_jb51.jpg"><img src="http://files.jb51.net/file_images/article/201409/git_big_jb51.jpg" alt="img"></a></p>
<p>Git命令参考手册(文本版)</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line">git init                         <span class="comment"># 初始化本地git仓库（创建新仓库） </span></span><br><span class="line">git config --global user.name <span class="string">&quot;xxx&quot;</span>            <span class="comment"># 配置用户名 </span></span><br><span class="line">git config --global user.email <span class="string">&quot;xxx@xxx.com&quot;</span>       <span class="comment"># 配置邮件 </span></span><br><span class="line">git config --global color.ui <span class="literal">true</span>             <span class="comment"># git status等命令自动着色 </span></span><br><span class="line">git config --global color.status auto </span><br><span class="line">git config --global color.diff auto </span><br><span class="line">git config --global color.branch auto </span><br><span class="line">git config --global color.interactive auto </span><br><span class="line">git <span class="built_in">clone</span> git+ssh://git@192.168.53.168/VT.git       <span class="comment"># clone远程仓库 </span></span><br><span class="line">git status                        <span class="comment"># 查看当前版本状态（是否修改） </span></span><br><span class="line">git add xyz                        <span class="comment"># 添加xyz文件至index </span></span><br><span class="line">git add .                         <span class="comment"># 增加当前子目录下所有更改过的文件至index </span></span><br><span class="line">git commit -m <span class="string">&#x27;xxx&#x27;</span>                    <span class="comment"># 提交 </span></span><br><span class="line">git commit --amend -m <span class="string">&#x27;xxx&#x27;</span>                <span class="comment"># 合并上一次提交（用于反复修改） </span></span><br><span class="line">git commit -am <span class="string">&#x27;xxx&#x27;</span>                   <span class="comment"># 将add和commit合为一步 </span></span><br><span class="line">git <span class="built_in">rm</span> xxx                        <span class="comment"># 删除index中的文件 </span></span><br><span class="line">git <span class="built_in">rm</span> -r *                        <span class="comment"># 递归删除 </span></span><br><span class="line">git <span class="built_in">log</span>                          <span class="comment"># 显示提交日志 </span></span><br><span class="line">git <span class="built_in">log</span> -1                        <span class="comment"># 显示1行日志 -n为n行 </span></span><br><span class="line">git <span class="built_in">log</span> -5</span><br><span class="line">git <span class="built_in">log</span> --<span class="built_in">stat</span>                      <span class="comment"># 显示提交日志及相关变动文件 </span></span><br><span class="line">git <span class="built_in">log</span> -p -m </span><br><span class="line">git show dfb02e6e4f2f7b573337763e5c0013802e392818     <span class="comment"># 显示某个提交的详细内容 </span></span><br><span class="line">git show dfb02                      <span class="comment"># 可只用commitid的前几位 </span></span><br><span class="line">git show HEAD                       <span class="comment"># 显示HEAD提交日志 </span></span><br><span class="line">git show HEAD^                      <span class="comment"># 显示HEAD的父（上一个版本）的提交日志 ^^为上两个版本 ^5为上5个版本 </span></span><br><span class="line">git tag                          <span class="comment"># 显示已存在的tag </span></span><br><span class="line">git tag -a v2.0 -m <span class="string">&#x27;xxx&#x27;</span>                 <span class="comment"># 增加v2.0的tag </span></span><br><span class="line">git show v2.0                       <span class="comment"># 显示v2.0的日志及详细内容 </span></span><br><span class="line">git <span class="built_in">log</span> v2.0                       <span class="comment"># 显示v2.0的日志 </span></span><br><span class="line">git diff                         <span class="comment"># 显示所有未添加至index的变更 </span></span><br><span class="line">git diff --cached                     <span class="comment"># 显示所有已添加index但还未commit的变更 </span></span><br><span class="line">git diff HEAD^                      <span class="comment"># 比较与上一个版本的差异 </span></span><br><span class="line">git diff HEAD -- ./lib                  <span class="comment"># 比较与HEAD版本lib目录的差异 </span></span><br><span class="line">git diff origin/master..master              <span class="comment"># 比较远程分支master上有本地分支master上没有的 </span></span><br><span class="line">git diff origin/master..master --<span class="built_in">stat</span>           <span class="comment"># 只显示差异的文件，不显示具体内容 </span></span><br><span class="line">git remote add origin git+ssh://git@192.168.53.168/VT.git <span class="comment"># 增加远程定义（用于push/pull/fetch） </span></span><br><span class="line">git branch                        <span class="comment"># 显示本地分支 </span></span><br><span class="line">git branch --contains 50089                <span class="comment"># 显示包含提交50089的分支 </span></span><br><span class="line">git branch -a                       <span class="comment"># 显示所有分支 </span></span><br><span class="line">git branch -r                       <span class="comment"># 显示所有原创分支 </span></span><br><span class="line">git branch --merged                    <span class="comment"># 显示所有已合并到当前分支的分支 </span></span><br><span class="line">git branch --no-merged                  <span class="comment"># 显示所有未合并到当前分支的分支 </span></span><br><span class="line">git branch -m master master_copy             <span class="comment"># 本地分支改名 </span></span><br><span class="line">git checkout -b master_copy                <span class="comment"># 从当前分支创建新分支master_copy并检出 </span></span><br><span class="line">git checkout -b master master_copy            <span class="comment"># 上面的完整版 </span></span><br><span class="line">git checkout features/performance             <span class="comment"># 检出已存在的features/performance分支 </span></span><br><span class="line">git checkout --track hotfixes/BJVEP933          <span class="comment"># 检出远程分支hotfixes/BJVEP933并创建本地跟踪分支</span></span><br><span class="line">git checkout v2.0                     <span class="comment"># 检出版本v2.0</span></span><br><span class="line">git checkout -b devel origin/develop           <span class="comment"># 从远程分支develop创建新本地分支devel并检出 </span></span><br><span class="line">git checkout -- README                  <span class="comment"># 检出head版本的README文件（可用于修改错误回退） </span></span><br><span class="line">git merge origin/master                  <span class="comment"># 合并远程master分支至当前分支 </span></span><br><span class="line">git cherry-pick ff44785404a8e               <span class="comment"># 合并提交ff44785404a8e的修改 </span></span><br><span class="line">git push origin master                  <span class="comment"># 将当前分支push到远程master分支 </span></span><br><span class="line">git push origin :hotfixes/BJVEP933            <span class="comment"># 删除远程仓库的hotfixes/BJVEP933分支 </span></span><br><span class="line">git push --tags                      <span class="comment"># 把所有tag推送到远程仓库 </span></span><br><span class="line">git fetch                         <span class="comment"># 获取所有远程分支（不更新本地分支，另需merge） </span></span><br><span class="line">git fetch --prune                     <span class="comment"># 获取所有原创分支并清除服务器上已删掉的分支 </span></span><br><span class="line">git pull origin master                  <span class="comment"># 获取远程分支master并merge到当前分支 </span></span><br><span class="line">git <span class="built_in">mv</span> README README2                   <span class="comment"># 重命名文件README为README2 </span></span><br><span class="line">git reset --hard HEAD                   <span class="comment"># 将当前版本重置为HEAD（通常用于merge失败回退） </span></span><br><span class="line">git rebase </span><br><span class="line">git branch -d hotfixes/BJVEP933              <span class="comment"># 删除分支hotfixes/BJVEP933（本分支修改已合并到其他分支） </span></span><br><span class="line">git branch -D hotfixes/BJVEP933              <span class="comment"># 强制删除分支hotfixes/BJVEP933 </span></span><br><span class="line">git ls-files                       <span class="comment"># 列出git index包含的文件 </span></span><br><span class="line">git show-branch                      <span class="comment"># 图示当前分支历史 </span></span><br><span class="line">git show-branch --all                   <span class="comment"># 图示所有分支历史 </span></span><br><span class="line">git whatchanged                      <span class="comment"># 显示提交历史对应的文件修改 </span></span><br><span class="line">git revert dfb02e6e4f2f7b573337763e5c0013802e392818    <span class="comment"># 撤销提交dfb02e6e4f2f7b573337763e5c0013802e392818 </span></span><br><span class="line">git ls-tree HEAD                     <span class="comment"># 内部命令：显示某个git对象 </span></span><br><span class="line">git rev-parse v2.0                    <span class="comment"># 内部命令：显示某个ref对于的SHA1 HASH </span></span><br><span class="line">git reflog                        <span class="comment"># 显示所有提交，包括孤立节点 </span></span><br><span class="line">git show HEAD@&#123;5&#125; </span><br><span class="line">git show master@&#123;yesterday&#125;                <span class="comment"># 显示master分支昨天的状态 </span></span><br><span class="line">git <span class="built_in">log</span> --pretty=format:<span class="string">&#x27;%h %s&#x27;</span> --graph          <span class="comment"># 图示提交日志 </span></span><br><span class="line">git show HEAD~3</span><br><span class="line">git show -s --pretty=raw 2be7fcb476 </span><br><span class="line">git stash                         <span class="comment"># 暂存当前修改，将所有至为HEAD状态 </span></span><br><span class="line">git stash list                      <span class="comment"># 查看所有暂存 </span></span><br><span class="line">git stash show -p stash@&#123;0&#125;                <span class="comment"># 参考第一次暂存 </span></span><br><span class="line">git stash apply stash@&#123;0&#125;                 <span class="comment"># 应用第一次暂存 </span></span><br><span class="line">git grep <span class="string">&quot;delete from&quot;</span>                  <span class="comment"># 文件中搜索文本“delete from” </span></span><br><span class="line">git grep -e <span class="string">&#x27;#define&#x27;</span> --and -e SORT_DIRENT </span><br><span class="line">git gc </span><br><span class="line">git fsck</span><br></pre></td></tr></table></figure>



<p><a target="_blank" rel="noopener" href="http://gitref.org/index.html">Git</a> 是一个很强大的分布式版本控制系统。它不但适用于管理大型开源软件的源代码，管理私人的文档和源代码也有很多优势。</p>
<h2 id="三、Git常用操作命令："><a href="#三、Git常用操作命令：" class="headerlink" title="三、Git常用操作命令："></a>三、Git常用操作命令：</h2><h3 id="1、远程仓库相关命令"><a href="#1、远程仓库相关命令" class="headerlink" title="1、远程仓库相关命令"></a>1、远程仓库相关命令</h3><p>检出仓库：<code>git clone git://github.com/jquery/jquery.git</code></p>
<p>查看远程仓库：<code> git remote -v</code></p>
<p>添加远程仓库：<code> git remote add [name] [url]</code></p>
<p>删除远程仓库：<code>git remote rm [name]</code></p>
<p>修改远程仓库：<code>git remote set-url --push [name] [newUrl]</code></p>
<p>拉取远程仓库：<code>git pull [remoteName] [localBranchName]</code></p>
<p>推送远程仓库：<code>git push [remoteName] [localBranchName]</code></p>
<p>如果想把本地的某个分支test提交到远程仓库，并作为远程仓库的master分支，或者作为另外一个名叫test的分支，如下：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git push origin <span class="built_in">test</span>:master     <span class="comment"># 提交本地test分支作为远程的master分支</span></span><br><span class="line"></span><br><span class="line">git push origin <span class="built_in">test</span>:<span class="built_in">test</span>        <span class="comment"># 提交本地test分支作为远程的test分支</span></span><br></pre></td></tr></table></figure>

<h3 id="2、分支-branch-操作相关命令"><a href="#2、分支-branch-操作相关命令" class="headerlink" title="2、分支(branch)操作相关命令"></a>2、分支(branch)操作相关命令</h3><p>查看本地分支： <code>git branch</code></p>
<p>查看远程分支： <code>git branch -r</code></p>
<p>创建本地分支： <code>git branch [name]</code> —-注意新分支创建后不会自动切换为当前分支</p>
<p>切换分支：<code>git checkout [name]</code></p>
<p>创建新分支并立即切换到新分支<code> git checkout -b [name]</code></p>
<p>删除分支： <code>git branch -d [name]</code> —- -d选项只能删除已经参与了合并的分支，对于未有合并的分支是无法删除的。如果想强制删除一个分支，可以使用-D选项</p>
<p>合并分支： <code>git merge [name]</code> —-将名称为[name]的分支与当前分支合并</p>
<p>创建远程分支(本地分支push到远程)： <code>git push origin [name]</code></p>
<p>删除远程分支： <code>git push origin :heads/[name]</code> 或  <code>gitpush origin :[name] </code></p>
<p>创建空的分支：(执行命令之前记得先提交你当前分支的修改，否则会被强制删干净没得后悔)</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git symbolic-ref HEAD refs/heads/[name]</span><br><span class="line"></span><br><span class="line"><span class="built_in">rm</span> .git/index</span><br><span class="line"></span><br><span class="line">git clean -fdx</span><br></pre></td></tr></table></figure>

<h3 id="3、版本-tag-操作相关命令"><a href="#3、版本-tag-操作相关命令" class="headerlink" title="3、版本(tag)操作相关命令"></a>3、版本(tag)操作相关命令</h3><p>查看版本：<code>git tag</code></p>
<p>创建版本：<code>git tag [name]</code></p>
<p>删除版本：<code>git tag -d [name]</code></p>
<p>查看远程版本： <code>git tag -r</code></p>
<p>创建远程版本(本地版本push到远程)： <code>git push origin [name]</code></p>
<p>删除远程版本： <code>git push origin :refs/tags/[name]</code></p>
<p>合并远程仓库的tag到本地：<code>git pull origin --tags</code></p>
<p>上传本地tag到远程仓库： <code>git push origin --tags</code></p>
<p>创建带注释的tag： <code>git tag -a [name] -m &#39;yourMessage&#39;</code></p>
<h3 id="4、子模块-submodule-相关操作命令"><a href="#4、子模块-submodule-相关操作命令" class="headerlink" title="4、子模块(submodule)相关操作命令"></a>4、子模块(submodule)相关操作命令</h3><p>添加子模块：<code> git submodule add [url] [path]</code></p>
<p>  如：<code>git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs</code></p>
<p>初始化子模块： <code>git submodule init</code>  —-只在首次检出仓库时运行一次就行</p>
<p>更新子模块：<code>git submodule update</code> —-每次更新或切换分支后都需要运行一下</p>
<p>删除子模块：（分4步走哦）</p>
<ol>
<li><p><code>git rm --cached [path]</code></p>
</li>
<li><p>编辑“.gitmodules”文件，将子模块的相关配置节点删除掉</p>
</li>
<li><p>编辑“ .git&#x2F;config”文件，将子模块的相关配置节点删除掉</p>
</li>
<li><p>手动删除子模块残留的目录</p>
</li>
</ol>
<h3 id="5、忽略一些文件、文件夹不提交"><a href="#5、忽略一些文件、文件夹不提交" class="headerlink" title="5、忽略一些文件、文件夹不提交"></a>5、忽略一些文件、文件夹不提交</h3><p>在仓库根目录下创建名称为“.gitignore”的文件，写入不需要的文件夹名或文件，每个元素占一行即可，如</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">target</span><br><span class="line"></span><br><span class="line">bin</span><br><span class="line"></span><br><span class="line">*.db</span><br></pre></td></tr></table></figure>

<p>Git 常用命令图表 </p>
<p><img src="https://img-blog.csdn.net/20180620113451746?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2hhbGFvZGE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt="img"></p>
<blockquote>
<p>原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/halaoda/article/details/78661334">https://blog.csdn.net/halaoda/article/details/78661334</a></p>
</blockquote>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Git/" rel="tag">Git</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-Vscode使用指南"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/Vscode%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/"
    >Vscode使用指南</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Vscode%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/" class="article-date">
  <time datetime="2022-01-22T15:09:16.180Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%A5%BD%E8%AE%B0%E6%80%A7%E4%B8%8D%E5%A6%82%E7%83%82%E7%AC%94%E5%A4%B4/">好记性不如烂笔头</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="Vscode使用指南"><a href="#Vscode使用指南" class="headerlink" title="Vscode使用指南"></a>Vscode使用指南</h1><h2 id="1-快速入门"><a href="#1-快速入门" class="headerlink" title="1.快速入门"></a>1.快速入门</h2><h3 id="下载与安装"><a href="#下载与安装" class="headerlink" title="下载与安装"></a>下载与安装</h3><p>官网：<a target="_blank" rel="noopener" href="https://code.visualstudio.com/">https://code.visualstudio.com/</a></p>
<p>根据电脑系统正常安装即可</p>
<h3 id="1-2-命令面板"><a href="#1-2-命令面板" class="headerlink" title="1.2 命令面板"></a>1.2 命令面板</h3><p>Ctrl + Shift + P 可调出命令面板</p>
<h3 id="1-3打开方式"><a href="#1-3打开方式" class="headerlink" title="1.3打开方式"></a>1.3打开方式</h3><ol>
<li><p>双击快捷键打开</p>
</li>
<li><p>通过命令行工具打开</p>
<p>打开终端工具，执行命令</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//打开指定文件夹 code 文件夹路径</span></span><br><span class="line">code D:\eclipse\workspace</span><br><span class="line"><span class="comment">//打开子文件夹 code ./子文件加名称</span></span><br><span class="line"> D:\eclipse\workspace&gt;code ./test    <span class="comment">//打开D:\eclipse\workspace下的test文件夹</span></span><br></pre></td></tr></table></figure>

<p>Windows自带两个命令行工具 CMD和PowerShell</p>
<p><strong>使用方法</strong></p>
<ol>
<li><p>Win+R输入cmd 或powershell</p>
</li>
<li><p>在指定目录地址栏输入cmd或powershell</p>
<p>进入到指定目录</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118164829200-1622786743.png" alt="image-20231118164829420"><br>删除地址路径，输入cmd或powershell回车</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118164856057-1112541008.png" alt="image-20231118164856451"></p>
<p>效果如下：</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118165130163-1992659133.png" alt="image-20231118165130425"></p>
</li>
</ol>
</li>
</ol>
<h2 id="2-代码编辑"><a href="#2-代码编辑" class="headerlink" title="2.代码编辑"></a>2.代码编辑</h2><h3 id="2-1光标移动"><a href="#2-1光标移动" class="headerlink" title="2.1光标移动"></a>2.1光标移动</h3><p>移到行首: Home</p>
<p>移到行尾:End</p>
<p>移动到文档的开头和末尾：Ctrl+ Home&#x2F;End</p>
<h3 id="2-2-删除，移动，注释"><a href="#2-2-删除，移动，注释" class="headerlink" title="2.2 删除，移动，注释"></a>2.2 删除，移动，注释</h3><p>Alt+⬆：向上移动当前行</p>
<p>Alt +⬇: 向下移动当前行</p>
<p>Alt + Shift +⬆：向上复制当前行</p>
<p>Alt + Shift +⬇:  向下复制当前行</p>
<p>Shift + Del（光标位置会移至行首）&#x2F;Ctrl + Shift + K(光标位置不变) :删除当前行 </p>
<p>单行注释：Ctrl + &#x2F;</p>
<p>块注释：Alt + Shift +A</p>
<h3 id="2-3代码格式化"><a href="#2-3代码格式化" class="headerlink" title="2.3代码格式化"></a>2.3代码格式化</h3><p>Alt + Shift + F</p>
<h3 id="2-4-批量操作"><a href="#2-4-批量操作" class="headerlink" title="2.4 批量操作"></a>2.4 批量操作</h3><p>按住Alt 然后鼠标选择需要修改的位置即可进行批量修改</p>
<p>选中代码段后按Alt + Shift + i可进行批量插入操作，左右方向键选择具体插入位置</p>
<h2 id="3-插件推荐"><a href="#3-插件推荐" class="headerlink" title="3.插件推荐"></a>3.插件推荐</h2><h3 id="3-1-Auto-Rename-Tag"><a href="#3-1-Auto-Rename-Tag" class="headerlink" title="3.1 Auto Rename Tag"></a>3.1 Auto Rename Tag</h3><p>自动重命名标签</p>
<h3 id="3-2-Better-Solarized-Dark主题"><a href="#3-2-Better-Solarized-Dark主题" class="headerlink" title="3.2 Better Solarized Dark主题"></a>3.2 Better Solarized Dark主题</h3><h3 id="3-3Chinese-简体中文"><a href="#3-3Chinese-简体中文" class="headerlink" title="3.3Chinese 简体中文"></a>3.3Chinese 简体中文</h3><h3 id="3-4-Code-Runner"><a href="#3-4-Code-Runner" class="headerlink" title="3.4 Code Runner"></a>3.4 Code Runner</h3><p>右键运行代码</p>
<h3 id="3-5Open-in-Browser"><a href="#3-5Open-in-Browser" class="headerlink" title="3.5Open in Browser"></a>3.5Open in Browser</h3><p>在浏览器中预览</p>
<h3 id="3-6-gitignore"><a href="#3-6-gitignore" class="headerlink" title="3.6 gitignore"></a>3.6 gitignore</h3><p>添加文件或者文件夹到gitignore</p>
<h3 id="3-7-import-Cost"><a href="#3-7-import-Cost" class="headerlink" title="3.7 import Cost"></a>3.7 import Cost</h3><p>引入文件分析</p>
<h3 id="3-8-Paste-Image"><a href="#3-8-Paste-Image" class="headerlink" title="3.8 Paste Image"></a>3.8 Paste Image</h3><p>快速将截图粘贴到Markdown文件</p>
<h3 id="3-9-Project-Manager"><a href="#3-9-Project-Manager" class="headerlink" title="3.9 Project Manager"></a>3.9 Project Manager</h3><p>项目管理工具</p>
<h3 id="3-10-Live-Server"><a href="#3-10-Live-Server" class="headerlink" title="3.10 Live Server"></a>3.10 Live Server</h3><p>本地服务器，右键菜单可以运行</p>
<h3 id="3-11-VScode-icons"><a href="#3-11-VScode-icons" class="headerlink" title="3.11 VScode-icons"></a>3.11 VScode-icons</h3><p>VScode图标</p>
<h3 id="3-12Document-This"><a href="#3-12Document-This" class="headerlink" title="3.12Document This"></a>3.12Document This</h3><p>快速对类和函数添加注释，通过按两次Ctrl + Alt + D可以快速添加注释。</p>
<h3 id="3-13-Language-PL-x2F-SQL"><a href="#3-13-Language-PL-x2F-SQL" class="headerlink" title="3.13 Language PL&#x2F;SQL"></a>3.13 Language PL&#x2F;SQL</h3><p>支持SQL语句</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Vscode/" rel="tag">Vscode</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-投屏神器Scrcpy基本使用"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/%E6%8A%95%E5%B1%8F%E7%A5%9E%E5%99%A8Scrcpy%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8/"
    >投屏神器Scrcpy基本使用</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/%E6%8A%95%E5%B1%8F%E7%A5%9E%E5%99%A8Scrcpy%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8/" class="article-date">
  <time datetime="2022-01-22T15:09:16.090Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%B0%8F%E6%8A%80%E8%83%BD/">小技能</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <blockquote>
<p><strong>github</strong>: <a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy">https://github.com/Genymobile/scrcpy</a></p>
</blockquote>
<p> <strong>选择下载版本</strong></p>
<p><img src="https://img-blog.csdnimg.cn/8b269d3465464b31a11a69b2c1e39b8d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"></p>
<p><strong>下载操作系统相应的安装包</strong></p>
<p><img src="https://img-blog.csdnimg.cn/8d63811ef1c84149b89d3b92ba9624fc.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"></p>
<h2 id="Scrcpy-基本简介"><a href="#Scrcpy-基本简介" class="headerlink" title="Scrcpy 基本简介"></a>Scrcpy 基本简介</h2><p>简单地来说，scrcpy就是通过adb调试的方式来将手机屏幕投到电脑上，并可以通过电脑控制您的Android设备。它可以通过USB连接，也可以通过Wifi连接（类似于隔空投屏），而且不需要任何root权限，不需要在手机里安装任何程序。scrcpy同时适用于GNU &#x2F; Linux，Windows和macOS。</p>
<p><strong>更多详细介绍见</strong> ：<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#readme">README.md</a></p>
<h2 id="Scrcpy-特征"><a href="#Scrcpy-特征" class="headerlink" title="Scrcpy 特征"></a>Scrcpy 特征</h2><p>它专注于：</p>
<ul>
<li><strong>亮度</strong>：原生，仅显示设备屏幕</li>
<li><strong>性能</strong>：30~120fps，取决于设备</li>
<li><strong>画质</strong>：1920×1080或以上</li>
<li><strong>低延迟</strong>：<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy/pull/646">35~70ms</a></li>
<li><strong>启动时间短</strong>：显示第一张图像约 1 秒</li>
<li><strong>非侵入性</strong>：设备上没有安装任何东西</li>
<li><strong>用户权益</strong>：无账户、无广告、无需网络</li>
<li><strong>自由</strong>：自由和开源软件</li>
</ul>
<p>其特点包括：</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#recording">记录</a></li>
<li>在<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#turn-screen-off">设备屏幕关闭的情况下进行</a>镜像</li>
<li>双向<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#copy-paste">复制粘贴</a></li>
<li><a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#capture-configuration">可配置的质量</a></li>
<li>设备屏幕<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#v4l2loopback">作为网络摄像头 (V4L2)</a>（仅限 Linux）</li>
<li><a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#physical-keyboard-simulation-hid">物理键盘模拟 (HID)</a> （仅限 Linux）</li>
<li>和更多…</li>
</ul>
<h2 id="使用要求"><a href="#使用要求" class="headerlink" title="使用要求"></a>使用要求</h2><ol>
<li>Android设备至少需要API 21（Android 5.0以上版本）;</li>
<li>确保在您的设备上启用了<a target="_blank" rel="noopener" href="https://developer.android.com/studio/command-line/adb.html#Enabling">adb调试</a>;</li>
<li>在某些设备上，您还需要启用<a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323">其他选项</a>以使用键盘和鼠标控制它。</li>
</ol>
<p>adb调试的开启一般是多次点击手机系统版本，</p>
<p>例如我的是  系统设置 &gt; 关于手机 &gt; 版本信息 &gt;  多次点击软件版本号，直到提示您已处于开发者模式，无需进行此操作</p>
<table>
<thead>
<tr>
<th></th>
<th align="center"><img src="https://img-blog.csdnimg.cn/7201b49ff8d94c218f981fa0de1dad03.png#pic_center" alt="在这里插入图片描述"></th>
<th></th>
</tr>
</thead>
</table>
<p>然后到系统设置 &gt; 开发者选项 &gt; 开启开发者选项 &gt;开启USB调试，如果有USB调试(安全模式)，一定要打开，开启USB调试，USB配置选择文件传输</p>
<table>
<thead>
<tr>
<th><img src="https://img-blog.csdnimg.cn/12ebfa2c4daf40ed9a44344a9aedb802.png#pic_center" alt="在这里插入图片描述"></th>
<th><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118160704909-1457463838.png" alt="image-20231118160704772"></th>
<th><img src="https://img-blog.csdnimg.cn/37a9751c754b495490687df732815a80.png#pic_center" alt="在这里插入图片描述"></th>
</tr>
</thead>
</table>
<h2 id="USB连接"><a href="#USB连接" class="headerlink" title="USB连接"></a>USB连接</h2><ol>
<li><p>手机通过USB连接电脑，首次连接会弹出是否信任该电脑，点击始终信任即可。</p>
</li>
<li><p>文件解压后在当前目录地址栏中输入<code>cmd</code>回车打开cmd窗口<br> <img src="https://img-blog.csdnimg.cn/eed7023ae12b4bcf8baccc81843e36ba.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"></p>
<p>  或者 <a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_50082325/article/details/121687653?spm=1001.2014.3001.5502">配置系统环境变量</a> 后 使用 Win + R 输入cmd 回车打开cmd窗口</p>
</li>
<li><p>执行命令 <code>adb usb</code> 查看是否连接成功</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">D:\Program Files (x86)\scrcpy<span class="literal">-win64-v1</span>.<span class="number">21</span>&gt;adb usb</span><br><span class="line">restarting <span class="keyword">in</span> USB mode</span><br></pre></td></tr></table></figure>
</li>
<li><p>输入命令 <code>scrcpy</code> 即可</p>
</li>
</ol>
<h2 id="无线连接"><a href="#无线连接" class="headerlink" title="无线连接"></a>无线连接</h2><p>1.确保手机与电脑在同一局域网中(ip的前三段相同)</p>
<pre><code>电脑可通过 `ipconfig` 查看，此处我的为 `192.168.5.236` ,上方显示 `VMware Network Adapter   `为虚拟机ip
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/eb28cb2bbc0643f2be320d4b16c114c1.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"></p>
<pre><code>    手机可通过 WLAN &gt; 已连接网络 &gt; IP 查看


 &lt;img src=&quot;https://img-blog.csdnimg.cn/4c45f0c67d574db7b0759d49f0fd05a8.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_13,color_FFFFFF,t_70,g_se,x_16#pic_center&quot; alt=&quot;image-20211202230435688&quot; style=&quot;zoom:50%;&quot; /&gt;                &lt;img src=&quot;https://img-blog.csdnimg.cn/ff75391524654429a895a155fb85c443.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_13,color_FFFFFF,t_70,g_se,x_16#pic_center&quot; alt=&quot;image-20211202230300907&quot; style=&quot;zoom:50%;&quot; /&gt;     

    此处我电脑和手机的ip段均为  `192.168.5`  属于同一ip段，所以在同一局域网中
</code></pre>
<ol start="2">
<li><p>手机先通过USB连接电脑(让电脑知道连接那台设备)</p>
</li>
<li><p>在scrcpy目录打开cmd窗口，参见上文</p>
</li>
<li><p>执行命令 <code>adb tcpip 端口号</code> 默认端口号为5555</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">D:\Program Files (x86)\scrcpy<span class="literal">-win64-v1</span>.<span class="number">21</span>&gt;adb tcpip <span class="number">5555</span></span><br><span class="line">restarting <span class="keyword">in</span> TCP mode port: <span class="number">5555</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>断开USB连接</p>
</li>
<li><p>执行命令 <code>adb connect ip : 端口</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">D:\Program Files (x86)\scrcpy-win64-v1.21&gt;adb connect 192.168.5.126:5555</span><br><span class="line">connected to 192.168.5.126:5555</span><br></pre></td></tr></table></figure>
</li>
<li><p>执行命令 <code>scrcpy</code> 进行无线连接即可</p>
</li>
</ol>
<h2 id="录制屏幕"><a href="#录制屏幕" class="headerlink" title="录制屏幕"></a>录制屏幕</h2><p>分为两种情况，一种是投屏状态下录屏：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">scrcpy --record file.mp4</span><br><span class="line">scrcpy -r file.mkv</span><br></pre></td></tr></table></figure>

<p>一种是非投屏状态下录屏：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">scrcpy --no-display --record file.mp4</span><br><span class="line">scrcpy -Nr file.mkv</span><br></pre></td></tr></table></figure>

<h2 id="快捷方式"><a href="#快捷方式" class="headerlink" title="快捷方式"></a>快捷方式</h2><p>在下面的列表中，MOD是快捷方式修饰符。<strong>默认情况下，它是 <code>(left)Alt</code>或 (left) Super</strong>。<br>可以使用 进行更改<code>--shortcut-mod</code>。可能的键<code>lctrl</code>，<code>rctrl</code>， <code>lalt</code>，<code>ralt</code>，<code>lsuper</code>和<code>rsuper</code>。例如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">#使用 RCtrl 作为快捷方式</span><br><span class="line">scrcpy --shortcut-mod=rctrl  #使用右侧ctrl作为快捷方式</span><br><span class="line">scrcpy --shortcut-mod=lctrl+lalt,lsuper  #使用 LCtrl+LAlt 或 LSuper 作为快捷方式</span><br></pre></td></tr></table></figure>

<p><em><a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Super_key_(keyboard_button)">Super</a>通常是Windows或Cmd键。</em></p>
<table>
<thead>
<tr>
<th>行动</th>
<th>捷径</th>
</tr>
</thead>
<tbody><tr>
<td>切换全屏模式</td>
<td>MOD+f</td>
</tr>
<tr>
<td>向左旋转显示</td>
<td>MOD+ ← <em>（左）</em></td>
</tr>
<tr>
<td>向右旋转显示</td>
<td>MOD+ → <em>（右）</em></td>
</tr>
<tr>
<td>将窗口大小调整为 1:1（像素完美）</td>
<td>MOD+g</td>
</tr>
<tr>
<td>调整窗口大小以去除黑色边框</td>
<td>MOD+ w| <em>双击左键¹</em></td>
</tr>
<tr>
<td>点击 <code>HOME</code>         （主页）</td>
<td>MOD+ h| <em>单击中键</em></td>
</tr>
<tr>
<td>点击 <code>BACK</code>            （返回）</td>
<td>MOD+ b| <em>右键单击²</em></td>
</tr>
<tr>
<td>点击 <code>APP_SWITCH</code>       （多任务栏）</td>
<td>MOD+ s| <em>第四次点击³</em></td>
</tr>
<tr>
<td>点击<code>MENU</code>（解锁屏幕）</td>
<td>MOD+m</td>
</tr>
<tr>
<td>点击 <code>VOLUME_UP</code>      （音量+）</td>
<td>MOD+ ↑ <em>（向上）</em></td>
</tr>
<tr>
<td>点击 <code>VOLUME_DOWN</code>          （音量-）</td>
<td>MOD+ ↓ <em>（下）</em></td>
</tr>
<tr>
<td>点击 <code>POWER</code></td>
<td>MOD+p</td>
</tr>
<tr>
<td>打开</td>
<td><em>右键单击²</em></td>
</tr>
<tr>
<td>关闭设备屏幕（保持镜像）</td>
<td>MOD+o</td>
</tr>
<tr>
<td>打开设备屏幕</td>
<td>MOD+Shift+o</td>
</tr>
<tr>
<td>旋转设备屏幕</td>
<td>MOD+r</td>
</tr>
<tr>
<td>展开通知面板</td>
<td>MOD+ n| <em>第 5 次点击³</em></td>
</tr>
<tr>
<td>展开设置面板</td>
<td>MOD+ n+ n| <em>双击 5 次点击³</em></td>
</tr>
<tr>
<td>折叠面板</td>
<td>MOD+Shift+n</td>
</tr>
<tr>
<td>复制到剪贴板⁴</td>
<td>MOD+c</td>
</tr>
<tr>
<td>剪切到剪贴板⁴</td>
<td>MOD+x</td>
</tr>
<tr>
<td>同步剪贴板和粘贴⁴</td>
<td>MOD+v</td>
</tr>
<tr>
<td>注入计算机剪贴板文本</td>
<td>MOD+Shift+v</td>
</tr>
<tr>
<td>启用&#x2F;禁用 FPS 计数器（在标准输出上）</td>
<td>MOD+i</td>
</tr>
<tr>
<td>双指缩放</td>
<td>Ctrl+<em>点击并移动</em></td>
</tr>
<tr>
<td>拖放 APK 文件</td>
<td>从电脑安装APK</td>
</tr>
<tr>
<td>拖放非 APK 文件</td>
<td><a target="_blank" rel="noopener" href="https://github.com/Genymobile/scrcpy#push-file-to-device">推送文件到设备</a></td>
</tr>
</tbody></table>
<p><em>¹双击黑色边框将其删除。</em><br><em>²如果屏幕已关闭，则右键单击可打开屏幕，否则按 BACK。</em><br><em>³第四个和第五个鼠标按钮，如果你的鼠标有它们。</em><br><em>⁴仅适用于 Android &gt;&#x3D; 7。</em></p>
<p>带有重复键的快捷方式通过松开并再次按下该键来执行。例如，要执行“扩展设置面板”：</p>
<ol>
<li>按住MOD。</li>
<li>然后双击n。</li>
<li>最后，释放MOD。</li>
</ol>
<p>所有Ctrl+<em>键</em>的快捷方式被转发到该设备，所以它们被激活的应用程序来处理。</p>
<h2 id="投屏不清晰问题"><a href="#投屏不清晰问题" class="headerlink" title="投屏不清晰问题"></a>投屏不清晰问题</h2><p>找到 <code>scrcpy.exe</code> 右键 &gt; 属性 &gt; 兼容性 &gt; 更改高DPI设置 &gt; 勾选替代高DPI缩放行为 &gt; 确定应用即可</p>
<p><img src="https://img-blog.csdnimg.cn/ba3c612ed7a0462bafe0210d8c193534.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pmC5YWJ5b-D5ZCR6Ziz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"></p>
<h2 id="常见错误"><a href="#常见错误" class="headerlink" title="常见错误"></a>常见错误</h2><ol>
<li><p><code>error: more than one device/emulator</code></p>
<p>报错原因：多个设备连接了电脑，导致adb无法识别操作具体哪台设备</p>
<p>可通过命令 <code>adb devices</code> 查看已连接设备</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">D:\Program Files (x86)\scrcpy<span class="literal">-win64-v1</span>.<span class="number">21</span>&gt;adb devices</span><br><span class="line">List of devices attached</span><br><span class="line">SKPN45IF8DBMRG59        device</span><br><span class="line"><span class="number">192.168</span>.<span class="number">5.126</span>:<span class="number">5555</span>      device</span><br></pre></td></tr></table></figure>

<ul>
<li><p>若想选择其中一个设备，可以执行以下命令连接其中一个设备</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">scrcpy --serial SKPN45IF8DBMRG59</span><br><span class="line"># 或者</span><br><span class="line">scrcpy -s SKPN45IF8DBMRG59</span><br></pre></td></tr></table></figure>
</li>
<li><p>也可以用<code>adb -s SKPN45IF8DBMRG59 shell</code>，进入该设备操作</p>
</li>
<li><p>若不想进入shell模式，则执行 <code>adb -s SKPN45IF8DBMRG59  指令</code>（如 adb -s SKPN45IF8DBMRG59 shell input keyevent 3）</p>
</li>
<li><p>如果只有一个模拟器和一个手机连着电脑</p>
<ul>
<li>可以用<code>adb -e</code> 来指明是操作模拟器（Emulator）</li>
<li>可以用<code>adb -d </code>来指明是操作设备（Device）</li>
</ul>
</li>
</ul>
<p>此处我是由于已进行无线连接（可以看到连接设备有 <code>192.168.5.126:5555      device</code>）又连接了US</p>
<p>只需拔掉USB，执行<code>scrcpy</code> 重新连接即可</p>
</li>
<li><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">[<span class="type">server</span>] ERROR: Exception on thread Thread[<span class="type">main</span>,<span class="number">5</span>,<span class="type">main</span>]</span><br><span class="line">java.lang.IllegalStateException</span><br><span class="line">        at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)</span><br><span class="line">        at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:<span class="number">2792</span>)</span><br><span class="line">        at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:<span class="number">110</span>)</span><br><span class="line">        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:<span class="number">91</span>)</span><br><span class="line">        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:<span class="number">65</span>)</span><br><span class="line">        at com.genymobile.scrcpy.Server.scrcpy(Server.java:<span class="number">93</span>)</span><br><span class="line">        at com.genymobile.scrcpy.Server.main(Server.java:<span class="number">309</span>)</span><br><span class="line">        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)</span><br><span class="line">        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:<span class="number">372</span>)</span><br><span class="line">INFO: Renderer: direct3d</span><br><span class="line">INFO: Initial texture: <span class="number">1080</span>x2336</span><br><span class="line">WARN: Device disconnected</span><br></pre></td></tr></table></figure>

<p>报错原因：已连接设备不支持默认分辨率设置</p>
<p>可使用如下命令打开</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 三者任选其一</span></span><br><span class="line">scrcpy <span class="literal">-m</span> <span class="number">1920</span></span><br><span class="line">scrcpy <span class="literal">-m</span> <span class="number">1024</span></span><br><span class="line">scrcpy <span class="literal">-m</span> <span class="number">800</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li><p><code>cannot connect to 192.168.X.X:5555: 由于目标计算机积极拒绝，无法连接。 (10061)</code></p>
<ol>
<li>首先检查要连接的手机是否已开启adb调试</li>
<li>开启手机adb服务端口及adb调试功能</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">D:\Program Files (x86)\scrcpy-win64-v1.21&gt;adb shell # 进入安卓系统shell</span><br><span class="line">PD1831:/ $ setprop service.adb.tcp.port 5555 #设置adb服务端口为5555，打开adb网络调试功能</span><br><span class="line">PD1831:/ $ setprop service.adb.tcp.port -1  # 打开adb的usb调试功能。</span><br><span class="line">PD1831:/ $ exit # 退出shell</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>cmd输入命令  <code>adb tcpip 5555</code>   让设备在 5555 端口监听 TCP&#x2F;IP 连接。</li>
<li>cmd 输入命令 <code>adb connect ip:端口</code> 即可连接成功</li>
</ol>
</li>
</ol>
</li>
</ol>
<blockquote>
<p><strong>参考</strong></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/was172/article/details/99705855">scrcpy——Android投屏神器(使用教程)</a></p>
</blockquote>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Scrcpy/" rel="tag">Scrcpy</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-Navicat 查看本地连接密码"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/Navicat%20%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E8%BF%9E%E6%8E%A5%E5%AF%86%E7%A0%81/"
    >Navicat 查看本地连接密码</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Navicat%20%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E8%BF%9E%E6%8E%A5%E5%AF%86%E7%A0%81/" class="article-date">
  <time datetime="2022-01-22T15:09:15.990Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%B0%8F%E6%8A%80%E8%83%BD/">小技能</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="Navicat-查看本地连接密码"><a href="#Navicat-查看本地连接密码" class="headerlink" title="Navicat 查看本地连接密码"></a>Navicat 查看本地连接密码</h3><h4 id="第一步，找到数据库连接登录密码（密文显示）"><a href="#第一步，找到数据库连接登录密码（密文显示）" class="headerlink" title="第一步，找到数据库连接登录密码（密文显示）"></a>第一步，找到数据库连接登录密码（密文显示）</h4><h5 id="方案一，用-navicat-导出连接，查看密码（推荐）"><a href="#方案一，用-navicat-导出连接，查看密码（推荐）" class="headerlink" title="方案一，用 navicat 导出连接，查看密码（推荐）"></a>方案一，用 navicat 导出连接，查看密码（推荐）</h5><p>文件 &gt; 导出连接</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223602608-1797248032.png" alt="image-20231116223601739"></p>
<p>选择要导出的连接，勾选导出密码</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223613539-218168637.png" alt="image-20211109142548787"></p>
<p>这样就得到了加密显示的连接密码</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223630441-2084299929.png" alt="image-20211109142824853"></p>
<h5 id="方案二，通过注册表查看加密显示的密码"><a href="#方案二，通过注册表查看加密显示的密码" class="headerlink" title="方案二，通过注册表查看加密显示的密码"></a>方案二，通过注册表查看加密显示的密码</h5><p>按快捷键 Win+R 在弹出的运行窗口中输入 regedit  点击确定 打开注册表编辑器</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223644861-290599067.png" alt="image-20211109143350339"></p>
<p>找到   计算机\HKEY_CURRENT_USER\SOFTWARE\PremiumSoft\NavicatMSSQL\Servers</p>
<p>Servers 目录下就是保存在本地的连接</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223654798-491183201.png" alt="image-20211109143737524"></p>
<p>双击右侧Pwd 即可赋值加密显示的密码字符串</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223709300-540846032.png" alt="image-20211109144046434"></p>
<h4 id="第二步，对密码解密"><a href="#第二步，对密码解密" class="headerlink" title="第二步，对密码解密"></a>第二步，对密码解密</h4><p>复制如下代码</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line"><span class="keyword">namespace</span> <span class="title class_">FatSmallTools</span>;</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">NavicatPassword</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$version</span> = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$aesKey</span> = <span class="string">&#x27;libcckeylibcckey&#x27;</span>;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$aesIv</span> = <span class="string">&#x27;libcciv libcciv &#x27;</span>;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$blowString</span> = <span class="string">&#x27;3DC5CA39&#x27;</span>;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$blowKey</span> = <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">protected</span> <span class="variable">$blowIv</span> = <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params"><span class="variable">$version</span> = <span class="number">12</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable language_">$this</span>-&gt;version = <span class="variable">$version</span>;</span><br><span class="line">        <span class="variable language_">$this</span>-&gt;blowKey = <span class="title function_ invoke__">sha1</span>(<span class="string">&#x27;3DC5CA39&#x27;</span>, <span class="literal">true</span>);</span><br><span class="line">        <span class="variable language_">$this</span>-&gt;blowIv = <span class="title function_ invoke__">hex2bin</span>(<span class="string">&#x27;d9c7c3c8870d64bd&#x27;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">encrypt</span>(<span class="params"><span class="variable">$string</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$result</span> = <span class="literal">FALSE</span>;</span><br><span class="line">        <span class="keyword">switch</span> (<span class="variable language_">$this</span>-&gt;version) &#123;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">11</span>:</span><br><span class="line">                <span class="variable">$result</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">encryptEleven</span>(<span class="variable">$string</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">12</span>:</span><br><span class="line">                <span class="variable">$result</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">encryptTwelve</span>(<span class="variable">$string</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">default</span>:</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="variable">$result</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">encryptEleven</span>(<span class="params"><span class="variable">$string</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$round</span> = <span class="title function_ invoke__">intval</span>(<span class="title function_ invoke__">floor</span>(<span class="title function_ invoke__">strlen</span>(<span class="variable">$string</span>) / <span class="number">8</span>));</span><br><span class="line">        <span class="variable">$leftLength</span> = <span class="title function_ invoke__">strlen</span>(<span class="variable">$string</span>) % <span class="number">8</span>;</span><br><span class="line">        <span class="variable">$result</span> = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">        <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;blowIv;</span><br><span class="line">        <span class="keyword">for</span> (<span class="variable">$i</span> = <span class="number">0</span>; <span class="variable">$i</span> &lt; <span class="variable">$round</span>; <span class="variable">$i</span>++) &#123;</span><br><span class="line">            <span class="variable">$temp</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">encryptBlock</span>(<span class="variable">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="title function_ invoke__">substr</span>(<span class="variable">$string</span>, <span class="number">8</span> * <span class="variable">$i</span>, <span class="number">8</span>), <span class="variable">$currentVector</span>));</span><br><span class="line">            <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="variable">$currentVector</span>, <span class="variable">$temp</span>);</span><br><span class="line">            <span class="variable">$result</span> .= <span class="variable">$temp</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (<span class="variable">$leftLength</span>) &#123;</span><br><span class="line">            <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">encryptBlock</span>(<span class="variable">$currentVector</span>);</span><br><span class="line">            <span class="variable">$result</span> .= <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="title function_ invoke__">substr</span>(<span class="variable">$string</span>, <span class="number">8</span> * <span class="variable">$i</span>, <span class="variable">$leftLength</span>), <span class="variable">$currentVector</span>);</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        <span class="keyword">return</span> <span class="title function_ invoke__">strtoupper</span>(<span class="title function_ invoke__">bin2hex</span>(<span class="variable">$result</span>));</span><br><span class="line"> </span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">encryptBlock</span>(<span class="params"><span class="variable">$block</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="title function_ invoke__">openssl_encrypt</span>(<span class="variable">$block</span>, <span class="string">&#x27;BF-ECB&#x27;</span>, <span class="variable">$this</span>-&gt;blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); </span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">decryptBlock</span>(<span class="params"><span class="variable">$block</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="title function_ invoke__">openssl_decrypt</span>(<span class="variable">$block</span>, <span class="string">&#x27;BF-ECB&#x27;</span>, <span class="variable">$this</span>-&gt;blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); </span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">xorBytes</span>(<span class="params"><span class="variable">$str1</span>, <span class="variable">$str2</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$result</span> = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">        <span class="keyword">for</span> (<span class="variable">$i</span> = <span class="number">0</span>; <span class="variable">$i</span> &lt; <span class="title function_ invoke__">strlen</span>(<span class="variable">$str1</span>); <span class="variable">$i</span>++) &#123;</span><br><span class="line">            <span class="variable">$result</span> .= <span class="title function_ invoke__">chr</span>(<span class="title function_ invoke__">ord</span>(<span class="variable">$str1</span>[<span class="variable">$i</span>]) ^ <span class="title function_ invoke__">ord</span>(<span class="variable">$str2</span>[<span class="variable">$i</span>]));</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="variable">$result</span>;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">encryptTwelve</span>(<span class="params"><span class="variable">$string</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$result</span> = <span class="title function_ invoke__">openssl_encrypt</span>(<span class="variable">$string</span>, <span class="string">&#x27;AES-128-CBC&#x27;</span>, <span class="variable">$this</span>-&gt;aesKey, OPENSSL_RAW_DATA, <span class="variable">$this</span>-&gt;aesIv);</span><br><span class="line">        <span class="keyword">return</span> <span class="title function_ invoke__">strtoupper</span>(<span class="title function_ invoke__">bin2hex</span>(<span class="variable">$result</span>));</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">decrypt</span>(<span class="params"><span class="variable">$string</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$result</span> = <span class="literal">FALSE</span>;</span><br><span class="line">        <span class="keyword">switch</span> (<span class="variable language_">$this</span>-&gt;version) &#123;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">11</span>:</span><br><span class="line">                <span class="variable">$result</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">decryptEleven</span>(<span class="variable">$string</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">12</span>:</span><br><span class="line">                <span class="variable">$result</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">decryptTwelve</span>(<span class="variable">$string</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">default</span>:</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="variable">$result</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">decryptEleven</span>(<span class="params"><span class="variable">$upperString</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$string</span> = <span class="title function_ invoke__">hex2bin</span>(<span class="title function_ invoke__">strtolower</span>(<span class="variable">$upperString</span>));</span><br><span class="line">        <span class="variable">$round</span> = <span class="title function_ invoke__">intval</span>(<span class="title function_ invoke__">floor</span>(<span class="title function_ invoke__">strlen</span>(<span class="variable">$string</span>) / <span class="number">8</span>));</span><br><span class="line">        <span class="variable">$leftLength</span> = <span class="title function_ invoke__">strlen</span>(<span class="variable">$string</span>) % <span class="number">8</span>;</span><br><span class="line">        <span class="variable">$result</span> = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">        <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;blowIv;</span><br><span class="line">        <span class="keyword">for</span> (<span class="variable">$i</span> = <span class="number">0</span>; <span class="variable">$i</span> &lt; <span class="variable">$round</span>; <span class="variable">$i</span>++) &#123;</span><br><span class="line">            <span class="variable">$encryptedBlock</span> = <span class="title function_ invoke__">substr</span>(<span class="variable">$string</span>, <span class="number">8</span> * <span class="variable">$i</span>, <span class="number">8</span>);</span><br><span class="line">            <span class="variable">$temp</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="variable">$this</span>-&gt;<span class="title function_ invoke__">decryptBlock</span>(<span class="variable">$encryptedBlock</span>), <span class="variable">$currentVector</span>);</span><br><span class="line">            <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="variable">$currentVector</span>, <span class="variable">$encryptedBlock</span>);</span><br><span class="line">            <span class="variable">$result</span> .= <span class="variable">$temp</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (<span class="variable">$leftLength</span>) &#123;</span><br><span class="line">            <span class="variable">$currentVector</span> = <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">encryptBlock</span>(<span class="variable">$currentVector</span>);</span><br><span class="line">            <span class="variable">$result</span> .= <span class="variable language_">$this</span>-&gt;<span class="title function_ invoke__">xorBytes</span>(<span class="title function_ invoke__">substr</span>(<span class="variable">$string</span>, <span class="number">8</span> * <span class="variable">$i</span>, <span class="variable">$leftLength</span>), <span class="variable">$currentVector</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="variable">$result</span>;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    </span><br><span class="line"> </span><br><span class="line">    <span class="keyword">protected</span> <span class="function"><span class="keyword">function</span> <span class="title">decryptTwelve</span>(<span class="params"><span class="variable">$upperString</span></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="variable">$string</span> = <span class="title function_ invoke__">hex2bin</span>(<span class="title function_ invoke__">strtolower</span>(<span class="variable">$upperString</span>));</span><br><span class="line">        <span class="keyword">return</span> <span class="title function_ invoke__">openssl_decrypt</span>(<span class="variable">$string</span>, <span class="string">&#x27;AES-128-CBC&#x27;</span>, <span class="variable">$this</span>-&gt;aesKey, OPENSSL_RAW_DATA, <span class="variable">$this</span>-&gt;aesIv);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="keyword">use</span> <span class="title">FatSmallTools</span>\<span class="title">NavicatPassword</span>;</span><br><span class="line"> </span><br><span class="line"><span class="comment">//需要指定版本，11或12</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">//$navicatPassword = new NavicatPassword(12);</span></span><br><span class="line"> </span><br><span class="line"><span class="variable">$navicatPassword</span> = <span class="keyword">new</span> <span class="title class_">NavicatPassword</span>(<span class="number">11</span>);</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="comment">//解密</span></span><br><span class="line"><span class="variable">$decode</span> = <span class="variable">$navicatPassword</span>-&gt;<span class="title function_ invoke__">decrypt</span>(<span class="string">&#x27;15057D7BA390&#x27;</span>);</span><br><span class="line"><span class="keyword">echo</span> <span class="variable">$decode</span>.<span class="string">&quot;\n&quot;</span>;</span><br></pre></td></tr></table></figure>

<p>打开网页  <a target="_blank" rel="noopener" href="https://tool.lu/coderunner/">https://tool.lu/coderunner/</a>   或   <a target="_blank" rel="noopener" href="http://www.dooccn.com/php7/">http://www.dooccn.com/php7/</a>  可在线运行代码</p>
<p>将原来内容替换为复制的代码块，将密码替换，点击执行 即可对密码进行解密</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223725447-1652122857.png" alt="image-20211109144818913"></p>
<p>如果执行后的密码乱码</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223743077-749080589.png" alt="image-20211109145143891"></p>
<p>更改一下版本即可</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231116223755429-136772544.png" alt="image-20211109145235122"></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Navicat/" rel="tag">Navicat</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-IDEA快捷键"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/IDEA%E5%BF%AB%E6%8D%B7%E9%94%AE/"
    >IDEA快捷键</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/IDEA%E5%BF%AB%E6%8D%B7%E9%94%AE/" class="article-date">
  <time datetime="2022-01-22T15:09:15.550Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%A5%BD%E8%AE%B0%E6%80%A7%E4%B8%8D%E5%A6%82%E7%83%82%E7%AC%94%E5%A4%B4/">好记性不如烂笔头</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="Ctrl"><a href="#Ctrl" class="headerlink" title="Ctrl"></a>Ctrl</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Ctrl + F</td>
<td align="left">在当前文件进行文本查找 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + R</td>
<td align="left">在当前文件进行文本替换 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Z</td>
<td align="left">撤销 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Y</td>
<td align="left">删除光标所在行 或 删除选中的行 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + X</td>
<td align="left">剪切光标所在行 或 剪切选择内容</td>
</tr>
<tr>
<td align="left">Ctrl + C</td>
<td align="left">复制光标所在行 或 复制选择内容</td>
</tr>
<tr>
<td align="left">Ctrl + D</td>
<td align="left">复制光标所在行 或 复制选择内容，并把复制内容插入光标位置下面 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + W</td>
<td align="left">递进式选择代码块。可选中光标所在的单词或段落，连续按会在原有选中的基础上再扩展选中范围 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + E</td>
<td align="left">显示最近打开的文件记录列表</td>
</tr>
<tr>
<td align="left">Ctrl + N</td>
<td align="left">根据输入的 <strong>类名</strong> 查找类文件</td>
</tr>
<tr>
<td align="left">Ctrl + G</td>
<td align="left">在当前文件跳转到指定行处</td>
</tr>
<tr>
<td align="left">Ctrl + J</td>
<td align="left">插入自定义动态代码模板</td>
</tr>
<tr>
<td align="left">Ctrl + P</td>
<td align="left">方法参数提示显示</td>
</tr>
<tr>
<td align="left">Ctrl + Q</td>
<td align="left">光标所在的变量 &#x2F; 类名 &#x2F; 方法名等上面（也可以在提示补充的时候按），显示文档内容</td>
</tr>
<tr>
<td align="left">Ctrl + U</td>
<td align="left">前往当前光标所在的方法的父类的方法 &#x2F; 接口定义</td>
</tr>
<tr>
<td align="left">Ctrl + B</td>
<td align="left">进入光标所在的方法&#x2F;变量的接口或是定义出，等效于 <code>Ctrl + 左键单击</code></td>
</tr>
<tr>
<td align="left">Ctrl + K</td>
<td align="left">版本控制提交项目，需要此项目有加入到版本控制才可用</td>
</tr>
<tr>
<td align="left">Ctrl + T</td>
<td align="left">版本控制更新项目，需要此项目有加入到版本控制才可用</td>
</tr>
<tr>
<td align="left">Ctrl + H</td>
<td align="left">显示当前类的层次结构</td>
</tr>
<tr>
<td align="left">Ctrl + O</td>
<td align="left">选择可重写的方法</td>
</tr>
<tr>
<td align="left">Ctrl + I</td>
<td align="left">选择可继承的方法</td>
</tr>
<tr>
<td align="left">Ctrl + +</td>
<td align="left">展开代码</td>
</tr>
<tr>
<td align="left">Ctrl + -</td>
<td align="left">折叠代码</td>
</tr>
<tr>
<td align="left">Ctrl + &#x2F;</td>
<td align="left">注释光标所在行代码，会根据当前不同文件类型使用不同的注释符号 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + [</td>
<td align="left">移动光标到当前所在代码的花括号开始位置</td>
</tr>
<tr>
<td align="left">Ctrl + ]</td>
<td align="left">移动光标到当前所在代码的花括号结束位置</td>
</tr>
<tr>
<td align="left">Ctrl + F1</td>
<td align="left">在光标所在的错误代码出显示错误信息</td>
</tr>
<tr>
<td align="left">Ctrl + F3</td>
<td align="left">调转到所选中的词的下一个引用位置</td>
</tr>
<tr>
<td align="left">Ctrl + F4</td>
<td align="left">关闭当前编辑文件</td>
</tr>
<tr>
<td align="left">Ctrl + F8</td>
<td align="left">在 Debug 模式下，设置光标当前行为断点，如果当前已经是断点则去掉断点</td>
</tr>
<tr>
<td align="left">Ctrl + F9</td>
<td align="left">执行 Make Project 操作</td>
</tr>
<tr>
<td align="left">Ctrl + F11</td>
<td align="left">选中文件 &#x2F; 文件夹，使用助记符设定 &#x2F; 取消书签</td>
</tr>
<tr>
<td align="left">Ctrl + F12</td>
<td align="left">弹出当前文件结构层，可以在弹出的层上直接输入，进行筛选</td>
</tr>
<tr>
<td align="left">Ctrl + Tab</td>
<td align="left">编辑窗口切换，如果在切换的过程又加按上delete，则是关闭对应选中的窗口</td>
</tr>
<tr>
<td align="left">Ctrl + Enter</td>
<td align="left">智能分隔行</td>
</tr>
<tr>
<td align="left">Ctrl + End</td>
<td align="left">跳到文件尾</td>
</tr>
<tr>
<td align="left">Ctrl + Home</td>
<td align="left">跳到文件头</td>
</tr>
<tr>
<td align="left">Ctrl + Space</td>
<td align="left">基础代码补全，默认在 Windows 系统上被输入法占用，需要进行修改，建议修改为 <code>Ctrl + 逗号</code> <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Delete</td>
<td align="left">删除光标后面的单词或是中文句</td>
</tr>
<tr>
<td align="left">Ctrl + BackSpace</td>
<td align="left">删除光标前面的单词或是中文句</td>
</tr>
<tr>
<td align="left">Ctrl + 1,2,3…9</td>
<td align="left">定位到对应数值的书签位置</td>
</tr>
<tr>
<td align="left">Ctrl + 左键单击</td>
<td align="left">在打开的文件标题上，弹出该文件路径</td>
</tr>
<tr>
<td align="left">Ctrl + 光标定位</td>
<td align="left">按 Ctrl 不要松开，会显示光标所在的类信息摘要</td>
</tr>
<tr>
<td align="left">Ctrl + 左方向键</td>
<td align="left">光标跳转到当前单词 &#x2F; 中文句的左侧开头位置</td>
</tr>
<tr>
<td align="left">Ctrl + 右方向键</td>
<td align="left">光标跳转到当前单词 &#x2F; 中文句的右侧开头位置</td>
</tr>
<tr>
<td align="left">Ctrl + 前方向键</td>
<td align="left">等效于鼠标滚轮向前效果</td>
</tr>
<tr>
<td align="left">Ctrl + 后方向键</td>
<td align="left">等效于鼠标滚轮向后效果</td>
</tr>
</tbody></table>
<h2 id="Alt"><a href="#Alt" class="headerlink" title="Alt"></a>Alt</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Alt + &#96;</td>
<td align="left">显示版本控制常用操作菜单弹出层</td>
</tr>
<tr>
<td align="left">Alt + Q</td>
<td align="left">弹出一个提示，显示当前类的声明 &#x2F; 上下文信息</td>
</tr>
<tr>
<td align="left">Alt + F1</td>
<td align="left">显示当前文件选择目标弹出层，弹出层中有很多目标可以进行选择</td>
</tr>
<tr>
<td align="left">Alt + F2</td>
<td align="left">对于前面页面，显示各类浏览器打开目标选择弹出层</td>
</tr>
<tr>
<td align="left">Alt + F3</td>
<td align="left">选中文本，逐个往下查找相同文本，并高亮显示</td>
</tr>
<tr>
<td align="left">Alt + F7</td>
<td align="left">查找光标所在的方法 &#x2F; 变量 &#x2F; 类被调用的地方</td>
</tr>
<tr>
<td align="left">Alt + F8</td>
<td align="left">在 Debug 的状态下，选中对象，弹出可输入计算表达式调试框，查看该输入内容的调试结果</td>
</tr>
<tr>
<td align="left">Alt + Home</td>
<td align="left">定位 &#x2F; 显示到当前文件的 <code>Navigation Bar</code></td>
</tr>
<tr>
<td align="left">Alt + Enter</td>
<td align="left">IntelliJ IDEA 根据光标所在问题，提供快速修复选择，光标放在的位置不同提示的结果也不同 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Alt + Insert</td>
<td align="left">代码自动生成，如生成对象的 set &#x2F; get 方法，构造函数，toString() 等</td>
</tr>
<tr>
<td align="left">Alt + 左方向键</td>
<td align="left">按左方向切换当前已打开的文件视图</td>
</tr>
<tr>
<td align="left">Alt + 右方向键</td>
<td align="left">按右方向切换当前已打开的文件视图</td>
</tr>
<tr>
<td align="left">Alt + 前方向键</td>
<td align="left">当前光标跳转到当前文件的前一个方法名位置</td>
</tr>
<tr>
<td align="left">Alt + 后方向键</td>
<td align="left">当前光标跳转到当前文件的后一个方法名位置</td>
</tr>
<tr>
<td align="left">Alt + 1,2,3…9</td>
<td align="left">显示对应数值的选项卡，其中 1 是 Project 用得最多</td>
</tr>
</tbody></table>
<h2 id="Shift"><a href="#Shift" class="headerlink" title="Shift"></a>Shift</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Shift + F1</td>
<td align="left">如果有外部文档可以连接外部文档</td>
</tr>
<tr>
<td align="left">Shift + F2</td>
<td align="left">跳转到上一个高亮错误 或 警告位置</td>
</tr>
<tr>
<td align="left">Shift + F3</td>
<td align="left">在查找模式下，查找匹配上一个</td>
</tr>
<tr>
<td align="left">Shift + F4</td>
<td align="left">对当前打开的文件，使用新Windows窗口打开，旧窗口保留</td>
</tr>
<tr>
<td align="left">Shift + F6</td>
<td align="left">对文件 &#x2F; 文件夹 重命名</td>
</tr>
<tr>
<td align="left">Shift + F7</td>
<td align="left">在 Debug 模式下，智能步入。断点所在行上有多个方法调用，会弹出进入哪个方法</td>
</tr>
<tr>
<td align="left">Shift + F8</td>
<td align="left">在 Debug 模式下，跳出，表现出来的效果跟 <code>F9</code> 一样</td>
</tr>
<tr>
<td align="left">Shift + F9</td>
<td align="left">等效于点击工具栏的 <code>Debug</code> 按钮</td>
</tr>
<tr>
<td align="left">Shift + F10</td>
<td align="left">等效于点击工具栏的 <code>Run</code> 按钮</td>
</tr>
<tr>
<td align="left">Shift + F11</td>
<td align="left">弹出书签显示层</td>
</tr>
<tr>
<td align="left">Shift + Tab</td>
<td align="left">取消缩进</td>
</tr>
<tr>
<td align="left">Shift + ESC</td>
<td align="left">隐藏当前 或 最后一个激活的工具窗口</td>
</tr>
<tr>
<td align="left">Shift + End</td>
<td align="left">选中光标到当前行尾位置</td>
</tr>
<tr>
<td align="left">Shift + Home</td>
<td align="left">选中光标到当前行头位置</td>
</tr>
<tr>
<td align="left">Shift + Enter</td>
<td align="left">开始新一行。光标所在行下空出一行，光标定位到新行位置</td>
</tr>
<tr>
<td align="left">Shift + 左键单击</td>
<td align="left">在打开的文件名上按此快捷键，可以关闭当前打开文件</td>
</tr>
<tr>
<td align="left">Shift + 滚轮前后滚动</td>
<td align="left">当前文件的横向滚动轴滚动</td>
</tr>
</tbody></table>
<h2 id="Ctrl-Alt"><a href="#Ctrl-Alt" class="headerlink" title="Ctrl + Alt"></a>Ctrl + Alt</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Ctrl + Alt + L</td>
<td align="left">格式化代码，可以对当前文件和整个包目录使用 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Alt + O</td>
<td align="left">优化导入的类，可以对当前文件和整个包目录使用 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Alt + I</td>
<td align="left">光标所在行 或 选中部分进行自动代码缩进，有点类似格式化</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + T</td>
<td align="left">对选中的代码弹出环绕选项弹出层</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + J</td>
<td align="left">弹出模板选择窗口，讲选定的代码加入动态模板中</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + H</td>
<td align="left">调用层次</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + B</td>
<td align="left">在某个调用的方法名上使用会跳到具体的实现处，可以跳过接口</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + V</td>
<td align="left">快速引进变量</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + Y</td>
<td align="left">同步、刷新</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + S</td>
<td align="left">打开 IntelliJ IDEA 系统设置</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + F7</td>
<td align="left">显示使用的地方。寻找被该类或是变量被调用的地方，用弹出框的方式找出来</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + F11</td>
<td align="left">切换全屏模式</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + Enter</td>
<td align="left">光标所在行上空出一行，光标定位到新行</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + Home</td>
<td align="left">弹出跟当前文件有关联的文件弹出层</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + Space</td>
<td align="left">类名自动完成</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + 左方向键</td>
<td align="left">退回到上一个操作的地方 <code>（必备）**（注意与其他软件快捷键冲突）**</code></td>
</tr>
<tr>
<td align="left">Ctrl + Alt + 右方向键</td>
<td align="left">前进到上一个操作的地方 <code>（必备）**（注意与其他软件快捷键冲突）**</code></td>
</tr>
<tr>
<td align="left">Ctrl + Alt + 前方向键</td>
<td align="left">在查找模式下，跳到上个查找的文件</td>
</tr>
<tr>
<td align="left">Ctrl + Alt + 后方向键</td>
<td align="left">在查找模式下，跳到下个查找的文件</td>
</tr>
</tbody></table>
<h2 id="Ctrl-Shift"><a href="#Ctrl-Shift" class="headerlink" title="Ctrl + Shift"></a>Ctrl + Shift</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Ctrl + Shift + F</td>
<td align="left">根据输入内容查找整个项目 或 指定目录内文件 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + R</td>
<td align="left">根据输入内容替换对应内容，范围为整个项目 或 指定目录内文件 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + J</td>
<td align="left">自动将下一行合并到当前行末尾 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Z</td>
<td align="left">取消撤销 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + W</td>
<td align="left">递进式取消选择代码块。可选中光标所在的单词或段落，连续按会在原有选中的基础上再扩展取消选中范围 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + N</td>
<td align="left">通过文件名定位 &#x2F; 打开文件 &#x2F; 目录，打开目录需要在输入的内容后面多加一个正斜杠 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + U</td>
<td align="left">对选中的代码进行大 &#x2F; 小写轮流转换 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + T</td>
<td align="left">对当前类生成单元测试类，如果已经存在的单元测试类则可以进行选择</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + C</td>
<td align="left">复制当前文件磁盘路径到剪贴板</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + V</td>
<td align="left">弹出缓存的最近拷贝的内容管理器弹出层</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + E</td>
<td align="left">显示最近修改的文件列表的弹出层</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + H</td>
<td align="left">显示方法层次结构</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + B</td>
<td align="left">跳转到类型声明处</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + I</td>
<td align="left">快速查看光标所在的方法 或 类的定义</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + A</td>
<td align="left">查找动作 &#x2F; 设置</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + &#x2F;</td>
<td align="left">代码块注释 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + [</td>
<td align="left">选中从光标所在位置到它的顶部中括号位置</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + ]</td>
<td align="left">选中从光标所在位置到它的底部中括号位置</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + +</td>
<td align="left">展开所有代码</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + -</td>
<td align="left">折叠所有代码</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + F7</td>
<td align="left">高亮显示所有该选中文本，按Esc高亮消失</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + F8</td>
<td align="left">在 Debug 模式下，指定断点进入条件</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + F9</td>
<td align="left">编译选中的文件 &#x2F; 包 &#x2F; Module</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + F12</td>
<td align="left">编辑器最大化</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Space</td>
<td align="left">智能代码提示</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Enter</td>
<td align="left">自动结束代码，行末自动添加分号 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Backspace</td>
<td align="left">退回到上次修改的地方</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 1,2,3…9</td>
<td align="left">快速添加指定数值的书签</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 左方向键</td>
<td align="left">在代码文件上，光标跳转到当前单词 &#x2F; 中文句的左侧开头位置，同时选中该单词 &#x2F; 中文句</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 右方向键</td>
<td align="left">在代码文件上，光标跳转到当前单词 &#x2F; 中文句的右侧开头位置，同时选中该单词 &#x2F; 中文句</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 左方向键</td>
<td align="left">在光标焦点是在工具选项卡上，缩小选项卡区域</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 右方向键</td>
<td align="left">在光标焦点是在工具选项卡上，扩大选项卡区域</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 前方向键</td>
<td align="left">光标放在方法名上，将方法移动到上一个方法前面，调整方法排序</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + 后方向键</td>
<td align="left">光标放在方法名上，将方法移动到下一个方法前面，调整方法排序</td>
</tr>
</tbody></table>
<h2 id="Alt-Shift"><a href="#Alt-Shift" class="headerlink" title="Alt + Shift"></a>Alt + Shift</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Alt + Shift + N</td>
<td align="left">选择 &#x2F; 添加 task</td>
</tr>
<tr>
<td align="left">Alt + Shift + F</td>
<td align="left">显示添加到收藏夹弹出层</td>
</tr>
<tr>
<td align="left">Alt + Shift + C</td>
<td align="left">查看最近操作项目的变化情况列表</td>
</tr>
<tr>
<td align="left">Alt + Shift + F</td>
<td align="left">添加到收藏夹</td>
</tr>
<tr>
<td align="left">Alt + Shift + I</td>
<td align="left">查看项目当前文件</td>
</tr>
<tr>
<td align="left">Alt + Shift + F7</td>
<td align="left">在 Debug 模式下，下一步，进入当前方法体内，如果方法体还有方法，则会进入该内嵌的方法中，依此循环进入</td>
</tr>
<tr>
<td align="left">Alt + Shift + F9</td>
<td align="left">弹出 <code>Debug</code> 的可选择菜单</td>
</tr>
<tr>
<td align="left">Alt + Shift + F10</td>
<td align="left">弹出 <code>Run</code> 的可选择菜单</td>
</tr>
<tr>
<td align="left">Alt + Shift + 左键双击</td>
<td align="left">选择被双击的单词 &#x2F; 中文句，按住不放，可以同时选择其他单词 &#x2F; 中文句</td>
</tr>
<tr>
<td align="left">Alt + Shift + 前方向键</td>
<td align="left">移动光标所在行向上移动</td>
</tr>
<tr>
<td align="left">Alt + Shift + 后方向键</td>
<td align="left">移动光标所在行向下移动</td>
</tr>
</tbody></table>
<h2 id="Ctrl-Shift-Alt"><a href="#Ctrl-Shift-Alt" class="headerlink" title="Ctrl + Shift + Alt"></a>Ctrl + Shift + Alt</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Ctrl + Shift + Alt + V</td>
<td align="left">无格式黏贴</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Alt + N</td>
<td align="left">前往指定的变量 &#x2F; 方法</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Alt + S</td>
<td align="left">打开当前项目设置</td>
</tr>
<tr>
<td align="left">Ctrl + Shift + Alt + C</td>
<td align="left">复制参考信息</td>
</tr>
</tbody></table>
<h2 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h2><table>
<thead>
<tr>
<th align="left">快捷键</th>
<th align="left">介绍</th>
</tr>
</thead>
<tbody><tr>
<td align="left">F2</td>
<td align="left">跳转到下一个高亮错误 或 警告位置 <code>（必备）</code></td>
</tr>
<tr>
<td align="left">F3</td>
<td align="left">在查找模式下，定位到下一个匹配处</td>
</tr>
<tr>
<td align="left">F4</td>
<td align="left">编辑源</td>
</tr>
<tr>
<td align="left">F7</td>
<td align="left">在 Debug 模式下，进入下一步，如果当前行断点是一个方法，则进入当前方法体内，如果该方法体还有方法，则不会进入该内嵌的方法中</td>
</tr>
<tr>
<td align="left">F8</td>
<td align="left">在 Debug 模式下，进入下一步，如果当前行断点是一个方法，则不进入当前方法体内</td>
</tr>
<tr>
<td align="left">F9</td>
<td align="left">在 Debug 模式下，恢复程序运行，但是如果该断点下面代码还有断点则停在下一个断点上</td>
</tr>
<tr>
<td align="left">F11</td>
<td align="left">添加书签</td>
</tr>
<tr>
<td align="left">F12</td>
<td align="left">回到前一个工具窗口</td>
</tr>
<tr>
<td align="left">Tab</td>
<td align="left">缩进</td>
</tr>
<tr>
<td align="left">ESC</td>
<td align="left">从工具窗口进入代码文件窗口</td>
</tr>
<tr>
<td align="left">连按两次Shift</td>
<td align="left">弹出 <code>Search Everywhere</code> 弹出层</td>
</tr>
</tbody></table>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/IDEA/" rel="tag">IDEA</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-Gitignore 配置语法"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/Gitignore%20%E9%85%8D%E7%BD%AE%E8%AF%AD%E6%B3%95/"
    >Gitignore 配置语法</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Gitignore%20%E9%85%8D%E7%BD%AE%E8%AF%AD%E6%B3%95/" class="article-date">
  <time datetime="2022-01-22T15:09:15.460Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%A5%BD%E8%AE%B0%E6%80%A7%E4%B8%8D%E5%A6%82%E7%83%82%E7%AC%94%E5%A4%B4/">好记性不如烂笔头</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="Gitignore-配置语法"><a href="#Gitignore-配置语法" class="headerlink" title="Gitignore 配置语法"></a>Gitignore 配置语法</h1><blockquote>
<p>原文地址：<a target="_blank" rel="noopener" href="http://kuanghy.github.io/2016/05/17/gitignore">http://kuanghy.github.io/2016/05/17/gitignore</a></p>
</blockquote>
<p>Git 的 <code>.gitignore</code> 配置文件用于配置不需要加入到版本管理中的文件，配置好该文件能够为项目的管理带来很大的便利。它的配置与 <code>.gitconfig</code> 一样可以分为全局和局部两种。通过修改全局配置 git config 中的 excludesfile 配置向可以指定全局忽略文件。设置方法为：</p>
<blockquote>
<p>$git config –global core.excludesfile ~&#x2F;.gitignore</p>
</blockquote>
<p>这样，修改 <code>~/.gitignore</code> 这个文件将作用于所有 git 项目，并且作用于项目实例中的所有被跟踪的目录。比如说我们可以在该文件中添加 *.o 来忽略所有 .o 文件。</p>
<p>局部的配置只需要在项目目录中创建 <code>.gitignore</code> 文件即可。</p>
<h2 id="语法规范"><a href="#语法规范" class="headerlink" title="语法规范"></a>语法规范</h2><ul>
<li>空行或是以#开头的行即注释行将被忽略；</li>
<li>以斜杠 “&#x2F;” 结尾表示目录；</li>
<li>以星号 “*” 通配多个字符；</li>
<li>以问号 “?” 通配单个字符</li>
<li>以方括号 “[]” 包含单个字符的匹配列表；</li>
<li>以叹号 “!” 表示不忽略(跟踪)匹配到的文件或目录；</li>
<li>可以在前面添加斜杠 “&#x2F;” 来避免递归,下面的例子中可以很明白的看出来与下一条的区别。</li>
</ul>
<h2 id="配置文件示例"><a href="#配置文件示例" class="headerlink" title="配置文件示例"></a>配置文件示例</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"># 忽略 .a 文件</span><br><span class="line">*.a</span><br><span class="line"></span><br><span class="line"># 但否定忽略 lib.a, 尽管已经在前面忽略了 .a 文件</span><br><span class="line">!lib.a</span><br><span class="line"></span><br><span class="line"># 仅在当前目录下忽略 TODO 文件， 但不包括子目录下的 subdir/TODO</span><br><span class="line">/TODO</span><br><span class="line"></span><br><span class="line"># 忽略 build/ 文件夹下的所有文件</span><br><span class="line">build/</span><br><span class="line"></span><br><span class="line"># 忽略 doc/notes.txt, 不包括 doc/server/arch.txt</span><br><span class="line">doc/*.txt</span><br><span class="line"></span><br><span class="line"># 忽略所有的 .pdf 文件 在 doc/ directory 下的</span><br><span class="line">doc/**/*.pdf</span><br></pre></td></tr></table></figure>

<h2 id="配置文件模板"><a href="#配置文件模板" class="headerlink" title="配置文件模板"></a>配置文件模板</h2><p><a target="_blank" rel="noopener" href="https://github.com/">Github</a> 上为开发者提供了各种环境以及各种编程语言的 gitignore 文件配置模板</p>
<p><a target="_blank" rel="noopener" href="https://github.com/github/gitignore">https://github.com/github/gitignore</a></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Git/" rel="tag">Git</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-Git快速入门"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/Git%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/"
    >Git快速入门</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Git%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" class="article-date">
  <time datetime="2022-01-22T15:09:15.410Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143145322-413927943.png" alt="image-20231118143145163"> <code>everything-is-local</code> </p>
<blockquote>
<p>Author：Shine</p>
<p>Version：9.0.2</p>
<p>视频教程：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Mf4y117f3?p=5">https://www.bilibili.com/video/BV1Mf4y117f3?p=5</a></p>
<p>文章来自B站博主，如有侵权联系删除</p>
</blockquote>
<p>[TOC]</p>
<h3 id="一、引言"><a href="#一、引言" class="headerlink" title="一、引言"></a>一、引言</h3><hr>
<blockquote>
<ul>
<li><p>在单人开发过程中，需要进行版本管理，以利于开发进度的控制。</p>
</li>
<li><p>在多人开发过程中，不仅需要<strong>版本管理</strong>，还需要进行<strong>多人协同控制</strong>。</p>
</li>
</ul>
</blockquote>
<h3 id="二、介绍"><a href="#二、介绍" class="headerlink" title="二、介绍"></a>二、介绍</h3><hr>
<blockquote>
<ul>
<li>Git是一个<strong>开源的分布式版本控制系统</strong>，用于敏捷高效地处理任何或小或大的项目。</li>
<li>Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。</li>
<li>官网：<a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a></li>
</ul>
</blockquote>
<h3 id="三、Git安装"><a href="#三、Git安装" class="headerlink" title="三、Git安装"></a>三、Git安装</h3><hr>
<h4 id="3-1-下载Git"><a href="#3-1-下载Git" class="headerlink" title="3.1 下载Git"></a>3.1 下载Git</h4><blockquote>
<p>下载Git <a target="_blank" rel="noopener" href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">下载git</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143203621-2006321301.png" alt="image-20231118143203855"></td>
</tr>
</tbody></table>
<h4 id="3-2-安装"><a href="#3-2-安装" class="headerlink" title="3.2 安装"></a>3.2 安装</h4><blockquote>
<p>安装，除了安装位置外，其他一直下一步即可</p>
</blockquote>
<h4 id="3-3-基本配置"><a href="#3-3-基本配置" class="headerlink" title="3.3 基本配置"></a>3.3 基本配置</h4><blockquote>
<ul>
<li><p>安装后，打开git的cmd窗口 ，自报家门</p>
</li>
<li><p>如下信息会在提交代码时要使用，记录在你的每次提交中。以后才知道哪次提交是谁做的。</p>
</li>
</ul>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name &quot;Your Name&quot;  #用户名</span><br><span class="line">git config --global user.email &quot;email@example.com&quot;  #邮箱</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看信息</span></span><br><span class="line">git config -l </span><br></pre></td></tr></table></figure>

<h4 id="3-4-测试"><a href="#3-4-测试" class="headerlink" title="3.4 测试"></a>3.4 测试</h4><blockquote>
<p>测试：cmd中执行 ,查看git版本</p>
</blockquote>
<figure class="highlight cmd"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git version  </span><br></pre></td></tr></table></figure>

<h3 id="四、架构"><a href="#四、架构" class="headerlink" title="四、架构"></a>四、架构</h3><hr>
<blockquote>
<ul>
<li><p>版本库：工作区中有一个隐藏目录 <code>.git</code>，这个目录不属于工作区，而是git的 <code>版本库</code>，是git管理的所有内容 </p>
</li>
<li><p>暂存区：版本库中包含一个临时区域，保存下一步要提交的文件。</p>
</li>
<li><p>分支：版本库中包含若干分支，提交的文件存储在分支中</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">架构图</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143254796-1303010917.jpg" alt="暂存区"></td>
</tr>
</tbody></table>
<h3 id="五、仓库"><a href="#五、仓库" class="headerlink" title="五、仓库"></a>五、仓库</h3><hr>
<blockquote>
<p>对应的就是一个<a href="">目录</a>，这个目录中的所有文件被git管理起来。</p>
<p>以后会将一个<a href="">项目的根目录</a>，作为仓库。</p>
<p>仓库中的每个文件的改动 都由git跟踪。</p>
</blockquote>
<h4 id="5-1-新建仓库"><a href="#5-1-新建仓库" class="headerlink" title="5.1 新建仓库"></a>5.1 新建仓库</h4><blockquote>
<p>选择一个目录，执行指令：<a href="">git init</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">新建仓库</th>
<th align="center">仓库目录</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143314450-1391681047.png" alt="image-20231118143314616"></td>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143325501-711159843.png" alt="image-20231118143325822"></td>
</tr>
</tbody></table>
<h4 id="5-2-工作区"><a href="#5-2-工作区" class="headerlink" title="5.2 工作区"></a>5.2 工作区</h4><blockquote>
<p>执行<a href="">git init</a>的目录即为工作区，如上例，<a href="">D:\repo1</a>目录即为工作区【不包含<a href="">.git</a>目录】</p>
</blockquote>
<blockquote>
<p>所有文件，都首先在工作区新建，然后可以存入仓库(版本库)，进行版本控制。</p>
</blockquote>
<h4 id="5-3-暂存区"><a href="#5-3-暂存区" class="headerlink" title="5.3 暂存区"></a>5.3 暂存区</h4><blockquote>
<p>暂存区也在 <a href="">.git</a> 目录内，工作区的文件进入仓库时，要先进入暂存区。</p>
</blockquote>
<h4 id="5-4-分支"><a href="#5-4-分支" class="headerlink" title="5.4 分支"></a>5.4 分支</h4><blockquote>
<p>版本控制，简单说，就是记录文件的诸多版本，分支就是这些版本的最终记录位置。</p>
</blockquote>
<h3 id="六、基本操作"><a href="#六、基本操作" class="headerlink" title="六、基本操作"></a>六、基本操作</h3><hr>
<h4 id="6-1-查看仓库状态"><a href="#6-1-查看仓库状态" class="headerlink" title="6.1 查看仓库状态"></a>6.1 查看仓库状态</h4><blockquote>
<p>执行 <a href="">git  status</a> 可以看到工作区中文件的状态</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">未记录过的文件，是未跟踪状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143339822-1000730504.png" alt="image-20231118143339996"></td>
</tr>
</tbody></table>
<h4 id="6-2-暂存文件"><a href="#6-2-暂存文件" class="headerlink" title="6.2 暂存文件"></a>6.2 暂存文件</h4><blockquote>
<p>执行 <a href="">git add .</a> 将工作区中的文件全部<a href="">存入暂存区</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">将工作区中的文件存入暂存区</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143353117-1494446251.png" alt="image-20231118143353312"></td>
</tr>
</tbody></table>
<h4 id="6-3-提交文件"><a href="#6-3-提交文件" class="headerlink" title="6.3 提交文件"></a>6.3 提交文件</h4><blockquote>
<p>执行 <a href="">git commit -m “这里写提交的描述信息”</a> 作用是将暂存区的文件存入分支，形成一个版本</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">提交文件，形成一个版本</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143405386-1075167476.png" alt="image-20231118143405652"></td>
</tr>
</tbody></table>
<h3 id="七、远程仓库"><a href="#七、远程仓库" class="headerlink" title="七、远程仓库"></a>七、远程仓库</h3><hr>
<blockquote>
<p>第5章中的仓库，其实是本地仓库。</p>
<p>当多人协同开发时，每人都在自己的本地仓库维护版本。</p>
<p>但很重要的一点是，多人之间需要共享代码、合并代码，此时就需要一个<a href="">远程仓库</a>。</p>
</blockquote>
<h4 id="7-1-远程仓库工作模式"><a href="#7-1-远程仓库工作模式" class="headerlink" title="7.1 远程仓库工作模式"></a>7.1 远程仓库工作模式</h4><table>
<thead>
<tr>
<th align="center">远程仓库工作模式</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143432213-672457768.png" alt="image-20231118143432369"></td>
</tr>
</tbody></table>
<h4 id="7-2-远程仓库选型"><a href="#7-2-远程仓库选型" class="headerlink" title="7.2 远程仓库选型"></a>7.2 远程仓库选型</h4><blockquote>
<ul>
<li><p>有很多远程仓库可以选择，比如 github(<a target="_blank" rel="noopener" href="https://github.com/">https://github.com/</a>),码云(<a target="_blank" rel="noopener" href="https://gitee.com/">https://gitee.com/</a>)；</p>
<p> 此两种可以注册自己测试使用，但如果是商业项目，需要更多支持需要付费。</p>
</li>
<li><p>公司内部也可以有自己构建的远程仓库(<a target="_blank" rel="noopener" href="http://qianfeng.qfjava.cn:8087/users/sign_in">http://qianfeng.qfjava.cn:8087/users/sign_in</a>)。</p>
</li>
</ul>
</blockquote>
<h4 id="7-3-基本操作"><a href="#7-3-基本操作" class="headerlink" title="7.3 基本操作"></a>7.3 基本操作</h4><blockquote>
<p>每个开发人员，在面对远程仓库时，会面临的一些基本操作。</p>
</blockquote>
<h5 id="7-3-1-注册git服务器账号"><a href="#7-3-1-注册git服务器账号" class="headerlink" title="7.3.1 注册git服务器账号"></a>7.3.1 注册git服务器账号</h5><blockquote>
<p>在 <a target="_blank" rel="noopener" href="https://gitee.com/">码云</a> 注册账号，并登录。</p>
<p>进入公司后，很可能会使用公司自己搭建的git服务器，则账号向领导索要即可</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击注册，完成注册过程</th>
<th align="center"></th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143445731-1150239316.png" alt="image-20231118143446024"></td>
<td align="center"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">登录后显示主页</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143454963-1648476417.png" alt="image-20231118143455176"></td>
</tr>
</tbody></table>
<h5 id="7-3-2-新建远程仓库"><a href="#7-3-2-新建远程仓库" class="headerlink" title="7.3.2 新建远程仓库"></a>7.3.2 新建远程仓库</h5><table>
<thead>
<tr>
<th align="center">创建远程私有仓库-01</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143507151-1782049653.png" alt="image-20231118143507432"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">创建远程私有仓库-02</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143522420-251528464.png" alt="image-20231118143522580"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">创建远程私有仓库-03</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143544560-1907469803.png" alt="image-20231118143544615"></td>
</tr>
</tbody></table>
<h5 id="7-3-3-本地关联远程仓库"><a href="#7-3-3-本地关联远程仓库" class="headerlink" title="7.3.3 本地关联远程仓库"></a>7.3.3 本地关联远程仓库</h5><blockquote>
<p>本文档中选用仓库的 https协议的地址，将此地址关联到本地git中</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">如此后，本地即可用“origin” 代指远程仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143559478-2029771024.png" alt="image-20231118143559692"></td>
</tr>
</tbody></table>
<h5 id="7-3-4-推送文件到远程仓库"><a href="#7-3-4-推送文件到远程仓库" class="headerlink" title="7.3.4 推送文件到远程仓库"></a>7.3.4 推送文件到远程仓库</h5><blockquote>
<p>将本地仓库中已经commit的内容push到远程仓库，以共享自己的代码。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">push</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143611832-385341346.png" alt="image-20231118143611899"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">输入凭证，如此码云才能接受此次上传的内容</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143619342-1220170260.png" alt="image-20231118143619627"></td>
</tr>
</tbody></table>
<h5 id="7-3-5-克隆远程仓库"><a href="#7-3-5-克隆远程仓库" class="headerlink" title="7.3.5 克隆远程仓库"></a>7.3.5 克隆远程仓库</h5><blockquote>
<p>如果仓库已经由别人创建完毕，我们需要其中的内容，则可以通过 <a href="">git clone</a> 将其复制到本地。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">新建目录“repo2”，然后在其中执行 git clone</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143631629-1109707034.png" alt="image-20231118143631870"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">远程仓库，复制到本地，并自动初始化为一个本地仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143640754-1026926648.png" alt="image-20231118143641007"></td>
</tr>
</tbody></table>
<h5 id="7-3-6-代码共享"><a href="#7-3-6-代码共享" class="headerlink" title="7.3.6 代码共享"></a>7.3.6 代码共享</h5><blockquote>
<p>多人协同开发时，写好代码的<a href="">git push</a> 上传到远程仓库；需要代码的 <a href="">git pull</a> 拉取代码即可。 </p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">有人再次将本地仓库内容，上传到了远程仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143656532-1079550092.png" alt="image-20231118143656646"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">重点：此时另一方如果想获得更新，则需要做一次拉取 git pull</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143717784-116025964.png" alt="image-20231118143717839"></td>
</tr>
</tbody></table>
<h5 id="7-3-7-命令汇总"><a href="#7-3-7-命令汇总" class="headerlink" title="7.3.7 命令汇总"></a>7.3.7 命令汇总</h5><table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>git   remote   add  标识名(master)  远程地址</td>
<td>本地关联远程仓库</td>
</tr>
<tr>
<td>git   push  标识名  master</td>
<td>将本地仓库内容上传到远程仓库</td>
</tr>
<tr>
<td>git   pull  标识名   master</td>
<td>从远程仓库下载内容到本地仓库</td>
</tr>
<tr>
<td>git   clone  远程地址</td>
<td>将远程仓库复制到本地，并自动形成一个本地仓库</td>
</tr>
</tbody></table>
<h3 id="八、分支"><a href="#八、分支" class="headerlink" title="八、分支"></a>八、分支</h3><hr>
<h4 id="8-1-分支简介"><a href="#8-1-分支简介" class="headerlink" title="8.1 分支简介"></a>8.1 分支简介</h4><blockquote>
<ul>
<li><p>分支，是一个个版本最终存储的位置。</p>
</li>
<li><p>分支，就是一条时间线，每次<a href="">git commit</a>形成一个个版本，一个个版本依次存储在分支的一个个提交点上。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">分支由多个提交点组成，分支上会有一个指针，默认总是指向最新的提交点</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143731726-714202560.png" alt="image-20231118143732008"></td>
</tr>
</tbody></table>
<h4 id="8-2-分支操作"><a href="#8-2-分支操作" class="headerlink" title="8.2 分支操作"></a>8.2 分支操作</h4><h5 id="8-2-1-查看分支"><a href="#8-2-1-查看分支" class="headerlink" title="8.2.1 查看分支"></a>8.2.1 查看分支</h5><blockquote>
<ul>
<li><p>查看当前仓库的分支 <a href="">git branch</a></p>
</li>
<li><p>仓库中默认只有 master 分支</p>
</li>
<li><p>执行<a href="">git commit</a>时，默认是在master分支上保存版本。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">默认只有master分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143742537-332084392.png" alt="image-20231118143742800"></td>
</tr>
</tbody></table>
<h5 id="8-2-2-创建分支"><a href="#8-2-2-创建分支" class="headerlink" title="8.2.2 创建分支"></a>8.2.2 创建分支</h5><blockquote>
<ul>
<li><p>在商业项目开发过程中，我们不会轻易的在<a href="">master</a>分支上做操作。</p>
</li>
<li><p>我们会新建一个<a href="">开发用的分支</a>，在此分支上做版本的记录。</p>
<p>当代码确实没有问题时，才会将开发分支上成熟的代码版本添加到<a href="">master</a>分支上。</p>
</li>
<li><p>保证开发过程中，可以及时记录版本，又保证<a href="">master</a>分支上每个提交点都是稳健版本。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">创建分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143754848-957556736.png" alt="image-20231118143755022"></td>
</tr>
</tbody></table>
<h5 id="8-2-3-切换分支"><a href="#8-2-3-切换分支" class="headerlink" title="8.2.3 切换分支"></a>8.2.3 切换分支</h5><blockquote>
<ul>
<li><p>默认情况下，当前使用的分支是 master分支</p>
</li>
<li><p>可以切换到 dev分支，则后续的<a href="">git commit</a> 便会在dev分支上新建版本(提交点)</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">切换分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143804217-1900571447.png" alt="image-20231118143804500"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">再次查看分支情况</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143825025-689730459.png" alt="image-20231118143825278"></td>
</tr>
</tbody></table>
<h4 id="8-3-新建分支细节"><a href="#8-3-新建分支细节" class="headerlink" title="8.3 新建分支细节"></a>8.3 新建分支细节</h4><blockquote>
<p>新建分支时，新分支，默认有哪些内容？分支中包含了哪些次提交？</p>
</blockquote>
<h5 id="8-3-1-新分支初始内容"><a href="#8-3-1-新分支初始内容" class="headerlink" title="8.3.1 新分支初始内容"></a>8.3.1 新分支初始内容</h5><blockquote>
<p>每个分支都有一个<a href="">指针</a>，新建一个分支，首先是新建一个<a href="">指针</a>。</p>
<p>而且新分支的指针会和当前分支指向<a href="">同一个提交点</a>。</p>
<p>新分支包含的提交点就是从第一个提交点到分支指针指向的提交点。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">每个分支都有一个指针，新建一个分支，首先是新建一个指针</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143834749-218331524.png" alt="image-20231118143834977"></td>
</tr>
</tbody></table>
<h5 id="8-3-2-多分支走向"><a href="#8-3-2-多分支走向" class="headerlink" title="8.3.2 多分支走向"></a>8.3.2 多分支走向</h5><blockquote>
<p>在master分支和新分支，分别进行 <a href="">git add</a> 和 <a href="">git commit</a></p>
<p>分支情况如下图：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">master分支未动，在dev分支增加一次commit</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143844729-1685646913.png" alt="image-20231118143844920"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">master分支增加一个commit，dev分支再增加一个commit</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143853761-2100266460.png" alt="image-20231118143854036"></td>
</tr>
</tbody></table>
<h5 id="8-3-3-分支提交日志"><a href="#8-3-3-分支提交日志" class="headerlink" title="8.3.3 分支提交日志"></a>8.3.3 分支提交日志</h5><blockquote>
<p>查看分支的提交日志，进而看到分支中提交点的详细情况。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">提交情况如下</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143903270-1996358778.png" alt="image-20231118143903443"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看当前分支的提交日志</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143914236-1573204487.png" alt="image-20231118143914437"></td>
</tr>
</tbody></table>
<h4 id="8-4-分支合并"><a href="#8-4-分支合并" class="headerlink" title="8.4 分支合并"></a>8.4 分支合并</h4><blockquote>
<p>两个分支内容的合并</p>
</blockquote>
<blockquote>
<p><a href="">git merge 分支a</a>  合并分支a</p>
</blockquote>
<blockquote>
<p>合并的方式有两种：快速合并 和  三方合并。</p>
</blockquote>
<h5 id="8-4-1-快速合并"><a href="#8-4-1-快速合并" class="headerlink" title="8.4.1 快速合并"></a>8.4.1 快速合并</h5><blockquote>
<p>如果分支A当前的修改，是完全基于分支B的修改而来，则B分支合并A分支，就是移动指针即可。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并前分支状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143925643-969778620.png" alt="image-20231118143925883"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">快速合并效果（master 合并 dev）</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143935005-1043958158.png" alt="image-20231118143935281"></td>
</tr>
</tbody></table>
<h5 id="8-4-2-三方合并"><a href="#8-4-2-三方合并" class="headerlink" title="8.4.2 三方合并"></a>8.4.2 三方合并</h5><blockquote>
<p>在不具备快速合并的条件下，会采用三方合并。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并前，分支状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143943357-1762914460.png" alt="image-20231118143943601"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">三方合并，将<code>2</code>和<code>3</code>的更改都累加在<code>1</code>上，形成新的提交点</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143952957-919511155.png" alt="image-20231118143953218"></td>
</tr>
</tbody></table>
<blockquote>
<p>三方合并,它是把两个分支的最新快照（2 和 3）以及二者最近的共同祖先（1）进行三方合并，合并的结果是生成一个新的快照（并提交）</p>
</blockquote>
<h5 id="8-4-3-合并冲突"><a href="#8-4-3-合并冲突" class="headerlink" title="8.4.3 合并冲突"></a>8.4.3 合并冲突</h5><blockquote>
<p>两个分支进行合并，但它们含有对同一个文件的修改，则在合并时出现冲突，git无法决断该保留改文件哪个分支的修改。</p>
</blockquote>
<h6 id="8-4-3-1-冲突演示"><a href="#8-4-3-1-冲突演示" class="headerlink" title="8.4.3.1 冲突演示"></a>8.4.3.1 冲突演示</h6><blockquote>
<p>场景模拟如下：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">master分支修改hig.txt文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144006702-745001772.png" alt="image-20231118144006786"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">dev分支修改hig.txt</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144015375-1657289655.png" alt="image-20231118144015573"></td>
</tr>
</tbody></table>
<blockquote>
<p>在master分支 合并 dev分支</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并dev分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144026872-143489176.png" alt="image-20231118144027122"></td>
</tr>
</tbody></table>
<blockquote>
<p>此时，打开hig.txt 文件：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">冲突后，git会将两个分支的内容都展示在文件中</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144036387-1048232826.png" alt="image-20231118144036653"></td>
</tr>
</tbody></table>
<h6 id="8-4-3-2-冲突解决"><a href="#8-4-3-2-冲突解决" class="headerlink" title="8.4.3.2 冲突解决"></a>8.4.3.2 冲突解决</h6><blockquote>
<p>出现冲突后，如要由两个开发人员当面协商，该如何取舍，为冲突文件定义最终内容。</p>
<p>解决方案：</p>
<ol>
<li>保留某一方的，删除另一方的</li>
<li>保留双方的</li>
<li>但无论如何，要记得删除  <a href="">&lt;&lt;&lt;&lt;  &#x3D;&#x3D;&#x3D;&#x3D;  &gt;&gt;&gt;&gt;</a> 这些</li>
<li>本质是两人协商为冲突的内容，定制出合理的内容。</li>
</ol>
</blockquote>
<table>
<thead>
<tr>
<th align="center">根据协商，再次编辑文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144045018-327103143.png" alt="image-20231118144045314"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">提交 再次编辑后的文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144052315-1857104333.png" alt="image-20231118144052541"></td>
</tr>
</tbody></table>
<h3 id="九、Idea关联Git"><a href="#九、Idea关联Git" class="headerlink" title="九、Idea关联Git"></a>九、Idea关联Git</h3><hr>
<h4 id="9-1-关联Git"><a href="#9-1-关联Git" class="headerlink" title="9.1 关联Git"></a>9.1 关联Git</h4><blockquote>
<p><a href="">File &gt; Settings</a>  关联过程是自动的</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">此处关联是Idea可以自动完成的</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144102276-1322951384.png" alt="image-20231118144102453"></td>
</tr>
</tbody></table>
<h4 id="9-2-创建仓库"><a href="#9-2-创建仓库" class="headerlink" title="9.2 创建仓库"></a>9.2 创建仓库</h4><blockquote>
<ul>
<li><p>新建项目后，将项目目录创建为git仓库</p>
</li>
<li><p>注意： 要在建仓库前，设置<a href="">忽略文件 “.gitignore”</a></p>
<p>作用：被忽略的文件会被版本记录忽略，版本中不包含它们。</p>
<p>范围：不需要和其他开发共享的文件，具体见下图。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">创建仓库前，先添加忽略文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144114639-1865611775.png" alt="image-20231118144114831"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">将项目目录初始化为一个仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144127524-757573136.png" alt="image-20231118144127703"></td>
</tr>
<tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144138727-831760856.png" alt="image-20231118144138949"></td>
</tr>
</tbody></table>
<h4 id="9-3-提交-commit"><a href="#9-3-提交-commit" class="headerlink" title="9.3 提交-commit"></a>9.3 提交-commit</h4><blockquote>
<p>创建好仓库后，做第一次提交。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择提交菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144148240-2083438892.png" alt="image-20231118144148478"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">选择提交文件，定义提交信息</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144159202-828407079.png" alt="image-20231118144159392"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">之后会有些友好提示，可以忽略，点击<code>“commit”</code>即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144221102-1985964648.png" alt="image-20231118144221350"></td>
</tr>
</tbody></table>
<h4 id="9-4-创建分支"><a href="#9-4-创建分支" class="headerlink" title="9.4 创建分支"></a>9.4 创建分支</h4><blockquote>
<p>新建开发分支</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击右下角链接，即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144234827-1002888359.png" alt="image-20231118144235117"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">新建分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144245538-757811888.png" alt="image-20231118144245774"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看当前分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144254918-773075157.png" alt="image-20231118144255200"></td>
</tr>
</tbody></table>
<h4 id="9-5-上传到远程仓库-push"><a href="#9-5-上传到远程仓库-push" class="headerlink" title="9.5 上传到远程仓库(push)"></a>9.5 上传到远程仓库(push)</h4><blockquote>
<ul>
<li><p>请首先参照第7章，创建一个远程仓库。</p>
</li>
<li><p>要求是裸库，且建议库名和项目名同名。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择<code>push</code>菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144306655-424837620.png" alt="image-20231118144306707"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">定义远程仓库地址</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144317202-300046318.png" alt="image-20231118144317457"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">执行，push操作</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144325365-236094702.png" alt="image-20231118144325553"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">push成功后 ，弹窗提示</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144338788-1427910688.png" alt="image-20231118144339015"></td>
</tr>
</tbody></table>
<h4 id="9-6-复制到本地仓库-clone"><a href="#9-6-复制到本地仓库-clone" class="headerlink" title="9.6 复制到本地仓库(clone)"></a>9.6 复制到本地仓库(clone)</h4><blockquote>
<p>如果有建好的远程仓库，比如公司内已经在用的仓库，或者github，码云上的一些公开仓库，</p>
<p>可以将远程仓库的项目复制到本地使用。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击克隆菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144349025-1428039724.png" alt="image-20231118144349039"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">输入如远程仓库地址</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144357535-1083350856.png" alt="image-20231118144357724"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">打开项目</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144406040-1306685056.png" alt="image-20231118144406209"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">打开项目，选项</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144418593-293642869.png" alt="image-20231118144418880"></td>
</tr>
</tbody></table>
<h4 id="9-7-更新本地项目"><a href="#9-7-更新本地项目" class="headerlink" title="9.7 更新本地项目"></a>9.7 更新本地项目</h4><blockquote>
<p>如果远程仓库有更新，则你的本地项目也需要一起更新。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择pull菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144431806-432832249.png" alt="image-20231118144431994"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">执行 pull操作</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144442620-1316725797.png" alt="image-20231118144442863"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">更新日志显示</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144450713-2041852087.png" alt="image-20231118144450831"></td>
</tr>
</tbody></table>
<h4 id="9-8-冲突解决"><a href="#9-8-冲突解决" class="headerlink" title="9.8 冲突解决"></a>9.8 冲突解决</h4><blockquote>
<p>合并分支时，如果出现冲突，则需要解决冲突。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">冲突出现，弹窗中可以选择如下</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144502121-1922182008.png" alt="image-20231118144502253"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">也可以直接修改冲突文件，然后commit即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144510394-2088787457.png" alt="image-20231118144510675"></td>
</tr>
</tbody></table>
<h3 id="十、多人协同开发"><a href="#十、多人协同开发" class="headerlink" title="十、多人协同开发"></a>十、多人协同开发</h3><hr>
<blockquote>
<p>多人开发协同，git操作</p>
</blockquote>
<h4 id="10-1-项目管理员-项目经理"><a href="#10-1-项目管理员-项目经理" class="headerlink" title="10.1 项目管理员( 项目经理 )"></a>10.1 项目管理员( 项目经理 )</h4><blockquote>
<p>1&gt; 由管理员负责创建一个远程库，初始的库中什么也没有，为裸库。库的名称建议和项目同名</p>
</blockquote>
<blockquote>
<p>2&gt; 管理员会在idea中创建一个初始项目,其中包含.gitignore文件。                                                                                          	 并在项目根目录下 建立本地库。并建立 dev分支。</p>
</blockquote>
<blockquote>
<p>3&gt; 管理员将本地库上传到远程库</p>
</blockquote>
<blockquote>
<p>4&gt; 将其他开发人员拉入远程库的 <a href="">开发成员列表中</a> ，使得其他开发人员可以访问该远程库。</p>
<p>流程如下：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击添加成员</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231117174343518-1649653212.jpg" alt="添加开发成员"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">选择直接添加</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231117174419353-504100498.jpg" alt="添加开发成员2"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">提交</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144522067-221438997.png" alt="image-20231118144522350"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看已添加的开发成员</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144530181-1345299533.png" alt="image-20231118144530320"></td>
</tr>
</tbody></table>
<blockquote>
<p>5&gt; master分支设置为 <a href="">protected分支</a>，只有管理员有权限将代码合并到其中。dev分支设置为 <a href="">常规分支</a>所有开发人员 都可以其中合并代码</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">进入分支设置</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144538253-1478156974.png" alt="image-20231118144538428"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">设置保护分支，让master分支不能被随更改</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144545130-945317719.png" alt="image-20231118144545311"></td>
</tr>
</tbody></table>
<h4 id="10-2-开发人员"><a href="#10-2-开发人员" class="headerlink" title="10.2 开发人员"></a>10.2 开发人员</h4><blockquote>
<ul>
<li><p>初始化：在idea中clone 远程库，获得项目。会建立本地库</p>
</li>
<li><p>后续的开发中，都要在dev分支上进行。开发完一个功能并测试通过后就commit 	 提交到本地的dev分支中，然后 上传(push)到远程dev分支中。	</p>
</li>
<li><p>需要更新项目内容时，通过 pull 从远程仓库拉取内容。																   	</p>
</li>
<li><p>注意：多人协同时，每次在 push 到远程库前，都先做一次pull，一来是把远程最新内容合并到本地，二来是核实本地内容是否和远程内容有冲突。</p>
</li>
<li><p>后续的开发，会接到一个个的功能任务，往复操作 2&gt;、3&gt;、4&gt; 而已。</p>
</li>
</ul>
</blockquote>
<h3 id="十一、经典问题"><a href="#十一、经典问题" class="headerlink" title="十一、经典问题"></a>十一、经典问题</h3><hr>
<blockquote>
<p>在使用https协议做push时，如果曾经使用过码云，但密码有过改动，此时会报错</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">使用https协议报错</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144556070-402910135.png" alt="image-20231118144556356"></td>
</tr>
</tbody></table>
<blockquote>
<p>解决方案:  <a href="">控制面板  》 凭据管理器 》</a> 删除对应凭证，再次使用时会提示重新输入密码。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">删除之前的码云凭证，然后重新push即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144603377-2004414503.png" alt="image-20231118144603568"></td>
</tr>
</tbody></table>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Git/" rel="tag">Git</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
    <article
  id="post-DNS记录类型详解"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2022/01/22/DNS%E8%AE%B0%E5%BD%95%E7%B1%BB%E5%9E%8B%E8%AF%A6%E8%A7%A3/"
    >DNS记录类型详解</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/DNS%E8%AE%B0%E5%BD%95%E7%B1%BB%E5%9E%8B%E8%AF%A6%E8%A7%A3/" class="article-date">
  <time datetime="2022-01-22T15:09:15.270Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%A5%BD%E8%AE%B0%E6%80%A7%E4%B8%8D%E5%A6%82%E7%83%82%E7%AC%94%E5%A4%B4/">好记性不如烂笔头</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <ol>
<li><strong>DNS</strong>：Domain Name System 域名管理系统 域名是由圆点分开一串单词或缩写组成的，每一个域名都对应一个惟一的IP地址，这一命名的方法或这样管理域名的系统叫做域名管理系统。DNS：Domain Name Server 域名服务器 域名虽然便于人们记忆，但网络中的计算机之间只能互相认识IP地址，它们之间的转换工作称为域名解析，域名解析需要由专门的域名解析服务器来完成，DNS 就是进行域名解析的服务器。 查看DNS更详细的解释</li>
<li><strong>A记录</strong>：A（Address）记录是用来指定主机名（或域名）对应的IP地址记录。用户可以将该域名下的网站服务器指向到自己的web server上。同时也可以设置域名的子域名。<strong>通俗来说A记录就是服务器的IP</strong>,域名绑定A记录就是告诉DNS,当你输入域名的时候给你引导向设置在DNS的A记录所对应的服务器。 简单的说，<strong>A记录是指定域名对应的IP地址</strong>。</li>
<li><strong>NS记录</strong>：NS（Name Server）记录是域名服务器记录，<strong>用来指定该域名由哪个DNS服务器来进行解析</strong>。 注册域名时，总有默认的DNS服务器，每个注册的域名都是由一个DNS域名服务器来进行解析的，DNS服务器NS记录地址一般以以下的形式出现： ns1.domain.com、ns2.domain.com等。 简单的说，<strong>NS记录是指定由哪个DNS服务器解析你的域名</strong>。</li>
<li><strong>MX记录</strong>：MX（Mail Exchanger）记录是邮件交换记录，它<strong>指向一个邮件服务器，用于电子邮件系统发邮件时根据收信人的地址后缀来定位邮件服务器</strong>。例如，当Internet上的某用户要发一封信给 <a href="mailto:&#117;&#115;&#101;&#114;&#x40;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#x63;&#x6f;&#x6d;">&#117;&#115;&#101;&#114;&#x40;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#x63;&#x6f;&#x6d;</a> 时，该用户的邮件系统通过DNS查找mydomain.com这个域名的MX记录，如果MX记录存在， 用户计算机就将邮件发送到MX记录所指定的邮件服务器上。</li>
<li><strong>CNAME记录</strong>：CNAME（Canonical Name ）别名记录，<strong>允许将多个名字映射到同一台计算机</strong>。通常用于同时提供WWW和MAIL服务的计算机。例如，有一台计算机名为 “host.mydomain.com”（A记录），它同时提供WWW和MAIL服务，为了便于用户访问服务。可以为该计算机设置两个别名（CNAME）：WWW和MAIL， 这两个别名的全称就“<a target="_blank" rel="noopener" href="http://www.mydomain.com”和“mail.mydomain.com”,实际上他们都指向/">www.mydomain.com”和“mail.mydomain.com”，实际上他们都指向</a> “host.mydomain.com”。</li>
<li><strong>TXT记录</strong>：一般<strong>指某个主机名或域名的说明</strong>，如：admin IN TXT “管理员, 电话：XXXXXXXXXXX”，mail IN TXT “邮件主机，存放在xxx , 管理人：AAA”，Jim IN TXT “contact: <a href="mailto:&#97;&#x62;&#99;&#64;&#x6d;&#97;&#x69;&#x6c;&#x73;&#101;&#x72;&#118;&#101;&#x72;&#x2e;&#x63;&#111;&#109;">&#97;&#x62;&#99;&#64;&#x6d;&#97;&#x69;&#x6c;&#x73;&#101;&#x72;&#118;&#101;&#x72;&#x2e;&#x63;&#111;&#109;</a>“，也就是您可以设置 TXT 内容以便使别人联系到您。 TXT的应用之一，SPF（Sender Policy Framework）反垃圾邮件。SPF是跟DNS相关的一项技术，它的内容写在DNS的TXT类型的记录里面。MX记录的作用是给寄信者指明某个域名的邮件服务器有哪些。SPF的作用跟MX相反，它向收信者表明，哪些邮件服务器是经过某个域名认可会发送邮件的。SPF的作用主要是反垃圾邮件，主要针对那些发信人伪造域名的垃圾邮件。例如：当邮件服务器收到自称发件人是<a href="mailto:&#115;&#112;&#97;&#x6d;&#64;&#x67;&#109;&#97;&#105;&#108;&#x2e;&#99;&#111;&#x6d;">&#115;&#112;&#97;&#x6d;&#64;&#x67;&#109;&#97;&#105;&#108;&#x2e;&#99;&#111;&#x6d;</a>的邮件，那么到底它是不是真的gmail.com的邮件服务器发过来的呢，我们可以查询gmail.com的SPF记录，以此防止别人伪造你来发邮件。</li>
<li><strong>TTL值</strong>：TTL（Time-To-Live）原理：TTL是IP协议包中的一个值，<strong>它告诉网络路由器包在网络中的时间是否太长而应被丢弃</strong>。有很多原因使包在一定时间内不能被传递到目的地。例如，不正确的路由表可能导致包的无限循环。一个解决方法就是在一段时间后丢弃这个包，然后给发送者一个报文，由发送者决定是否要重发。TTL的初值通常是系统缺省值，是包头中的8位的域。TTL的最初设想是确定一个时间范围，超过此时间就把包丢弃。由于每个路由器都至少要把TTL域减一，TTL通常表示包在被丢弃前最多能经过的路由器个数。<strong>当记数到0时，路由器决定丢弃该包，并发送一个ICMP报文给最初的发送者</strong>。 简单的说，<strong>TTL就是一条域名解析记录在DNS服务器中的存留时间</strong>。当各地的DNS服务器接受到解析请求时，就会向域名指定的NS服务器发出解析请求从而获得解析记录；在获得这个记录之后，记录会在DNS服务器中保存一段时间，这段时间内如果再接到这个域名的解析请求，DNS服务器将不再向NS服务器发出请求，而是直接返回刚才获得的记录，而<strong>这个记录在DNS服务器上保留的时间，就是TTL值</strong>。 TTL值设置的应用：一是增大TTL值，以节约域名解析时间，给网站访问加速。 一般情况下，域名的各种记录是极少更改的，很可能几个月、几年内都不会有什么变化。我们完全可以增大域名记录的TTL值让记录在各地DNS服务器中缓存的时间加长，这样在更长的一段时间内，我们访问这个网站时，本地ISP的DNS服务器就不需要向域名的NS服务器发出解析请求，而直接从缓存中返回域名解析记录。 二是减小TTL值，减少更换空间时的不可访问时间。 更换空间99.9%会有DNS记录更改的问题，因为缓存的问题，新的域名记录在有的地方可能生效了，但在有的地方可能等上一两天甚至更久才生效。结果就是有的人可能访问到了新服务器，有的人访问到了旧服务器。仅仅是访问的话，这也不是什么大问题，但如果涉及到了邮件发送，这个就有点麻烦了，说不定哪封重要信件就被发送到了那已经停掉的旧服务器上。 为了尽可能的减小这个各地的解析时间差，合理的做法是： 第一步，先查看域名当前的TTL值，我们假定是1天。 第二步，修改TTL值为可设定的最小值，可能的话，建议为1分钟，就是60。 第三步，等待一天，保证各地的DNS服务器缓存都过期并更新了记录。 第四步，设置修改新记录，这个时候各地的DNS就能以最快的速度更新到新的记录。 第五步，确认各地的DNS已经更新完成后，把TTL值设置成您想要的值。 <strong>一般操作系统的默认TTL值如下： TTL&#x3D;32 Windows 9x&#x2F;Me ，TTL&#x3D;64 LINUX ，TTL&#x3D;128 Windows 200x&#x2F;XP， TTL&#x3D;255 Unix</strong></li>
<li><strong>PTR值</strong>：PTR是pointer的简写，<strong>用于将一个IP地址映射到对应的域名，也可以看成是A记录的反向，IP地址的反向解析</strong>。 <strong>PTR主要用于邮件服务器</strong>，比如邮箱<a href="mailto:&#x41;&#x41;&#65;&#x40;&#x58;&#88;&#x58;&#46;&#x63;&#x6f;&#109;">&#x41;&#x41;&#65;&#x40;&#x58;&#88;&#x58;&#46;&#x63;&#x6f;&#109;</a>给邮箱<a href="mailto:&#66;&#x42;&#66;&#x40;&#121;&#x61;&#104;&#x6f;&#x6f;&#x2e;&#99;&#111;&#109;">&#66;&#x42;&#66;&#x40;&#121;&#x61;&#104;&#x6f;&#x6f;&#x2e;&#99;&#111;&#109;</a>发了一封邮件，yahoo邮件服务器接到邮件时会查看这封邮件的头文件，并分析是由哪个IP地址发出来的，然后根据这个IP地址进行反向解析，如果解析结果对应XXX.com的IP地址就接受这封邮件，反之则拒绝接收这封邮件。</li>
<li><strong>泛域名与泛解析</strong>：泛域名是指在一个域名根下，以 XXX.Domain.com的形式表示这个域名根所有未建立的子域名。 泛解析是把*.Domain.com的A记录解析到某个IP 地址上，通过访问任意的前缀.domain.com都能访问到你解析的站点上。</li>
<li><strong>域名绑定</strong>：域名绑定是指将域名指向服务器IP的操作。</li>
<li><strong>域名转向</strong>：域名转向又称为域名指向或域名转发，当用户地址栏中输入您的域名时，将会<strong>自动跳转到所指定的另一个域名</strong>。一般是使用短的好记的域名转向复杂难记的域名。</li>
</ol>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/DNS/" rel="tag">DNS</a></li></ul>

    </footer>
  </div>

    
 
   
  
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/7/">上一页</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><a class="page-number" href="/page/7/">7</a><span class="page-number current">8</span>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023
        <i class="ri-heart-fill heart_icon"></i> Shiguang
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="時光"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>